President Pedro Castillo was impeached after he tried to dissolve Congress in a move denounced as a coup.