This question already has an answer here:
I want to build a house around the player spawn in Minecraft 1.51.
When I spawned the first time I marked the block underneath my feet and built a house around it so I am safe when I spawn at night. The problem is that the spawn point moves everytime I die.
Why is that and how can I prevent it?