This is sort of what chaotic alignment is, I think. Lol'th probably thought it was particularly hilarious.
It's one of the many reasons playing a chaotic PC is difficult (IME). If you do get crowned C-, look forward to a nice crowning "gift" of corruption and ongoing corruption throughout the game.
How to avoid? Be invisible. High perception/necklace of the eye will help - if you can see anything coming before it can see you. Don't step on the altar unless you actually need to. Use "safe" altars like the Dwarftown one. With the items, you can collect eveything and dump it in a corner, but it's pretty annoying (or get a monster to pick it all up, then lead away and kill). Lightning/acid/fire if you're a wizard. Gelatinous cubes.
Maybe fate smiles + no cursing/dooming could give one turn before you get sacrificed? Still not sure though.
Gate closers: L+ DE Mindcrafter (p20), N= Gnomish Assasin (p20), N= Gnomish Mindcrafter (p23), N= Ratling Ranger (R49)