When you find yourself trying to remember a show (or any works) that's on the tip of your tongue but just out of reach, come here - the collective brain of the TVTropes community can probably help. Post all the details you can remember (examples help). If you're looking for a trope, head over to Trope Finder. Have general questions about tropes? Visit Ask The Tropers!
Kind of sounds like the classic story "Viy".
https://www.youtube.com/watch?v=y_W6ke4a-a0
Edited by OmeganianImpressively similar, but that wasn't it.
It does sound familiar, but only because I've read a version of the fairy tale; I don't know of any animated versions. But the one I read was called "The Princess in the Chest" or "The Princess in the Coffin", depending on the translator, and was from Denmark, in case that helps.
It was either an Anime or Western Animation Film, I think it was the former. After a Princess dies, a young soldier is ordered to guard the body for three nights until the funeral, but on the way is warned to hide in a different specific location (In the church) each night, so the demon or evil spirit possessing the princess won't find and eat him. Does this sound familiar to anyone?