Ok. This is a bit of a subtle point, and it is the essential idea behind separation of variables for pde's (we do not have a pde here, I know, but the essential idea is the same). The idea here is that each side of the equation has only one coordinate in it. Therefore, both sides must be constant. Otherwise, we could change just one side without changing the other, thus violating the equation. Does that make sense?