Prepositions are pretty tricky in English. Whether to use "in" or "on" is often just arbitrary, and we learn which to use case-by-case.
These are the "rules" as I know them:
"In" a bed means you are lying in bed with blankets or coverings over you, or at the very least (like say it is too hot for blankets), you are sleeping, about to sleep or just finished sleeping---or you are ill.
"On" a bed is when you are just resting there. For example you might even sit or stand "on" a bed. Or a salad might be served "on" a bed of lettuce.
A bed is "in" a room, almost never "of" a room.
"On" is used with floors of a building:
e.g. "Our office is on the 3rd floor." [you see how arbitrary this is? ... "On" usually would mean "on top of", but not with building floors.]
Houses or other buildings are usually located "on" a street, but "in" an alley.**
Of course that sentence as it stands is pretty cumbersome with all of those prepositions, and it would be more pleasant to read if it were broken up into more than one sentence or rephrased in some way. But as an example (of the place-prepositions), it should be:
"I was lying in my bed in my room on the first floor of the 2nd house
in the alley where I lived for more than a year."
, I think.
** Someone please correct me if I am wrong about street vs. alley [I know you will]. It might be OK to use either "on" or "in" with an alley, ... or it might even be regional.