S.H.
MANY changes developmentally in a 2 year old. And yes it affects sleep. And yes it is a phase but not one in which you can always control.
Because, it is developmental based.
And at this age, they do start to get, general "fears" of things and of the night and of the dark. Why? Because... their cognition is changing, their awareness is changing, and their imaginations. We cannot turn that, off.
MANY things going on at the SAME time.
And per routines and family changes.
A child's emotions at this age, is not even fully-developed yet, either.
So they are having to deal with many things. And the abstract as well. Which they do not yet, understand yet, either.
Comfort him.
No need to punish or scold for it.
It is most likely involuntary.
To a child this age, "fears" ARE real to them. Although as adults, it may not make sense.
And at this age, they begin to have night-mares too. Or night-terrors as well.
And yes, also, "separation anxiety" still exists. This occurs at other age stages too, but it is manifested differently, per age stage.
YES at stages like this, it will also affect a parents sleep. But it is childhood. It is temporary.
It will NOT be a permanent "habit."
Other phases will occur as well.
Or let him sleep, on a spot on the floor, of your room.
We do and did that with our 2 kids.
It works for us.
And they can go there if/when scared or if/when sick.
It is not a habit. It is a solution.
And we all get sleep, that way.