"We sleep in the castle."
Translation:Vi sover på slottet.
I think it's just one of those things you just have to memorise, it doesn't seem like there's a good reason.
I have read (but don't know if it's correct) that "på" is used instead of "i" for in public buildings, in places of work and in places of entertainment. Maybe a castle is considered a public building?
Being a native speaker of Danish I can tell that (as far as I know) there is no rule when you use "på" and "i". You say "på badeværelset" (in the bathroom) but also "i soveværelset" (in the sleeping room). Both words end with some form of "værelse" (room) so I guess it is a matter of remembering when to use what.
The public building rule seems ok as you say "på rådhuset" (in the city hall), "på sygehuset/hospitalet" (in the hospital), "på (tog)stationen" (in the train station), "på skolen" ((in the school). N.B.: "på skolen" is only used when you say that you psysically are INSIDE the school - if you want to say you did something in school you say "i skolen").
The only public place I can think of that uses "i" is "supermarked"-->"i supermarkedet".
Hope this helps