Altars can be quite mysterious to a beginning player.
Yet, they are very important for finishing the game. Here follows the most important information on altars in NetHack. Altars can occur anywhere in the main dungeon, sometimes even more than one on a level. See the quest.map file for more information on these. The effect of your actions depends not only on your luck and your current standings with your god, but most of all on the altar's alignment, compared to your own.