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.
Every altar has an alignment, which determines to what god it belongs.
The alignment of randomly generated altars is, as expected, random, and so is the altar in the Mines' Town. The altars in Gehennom are unaligned, since they all belong to Moloch, the renegade god. On the Astral Plane there is one altar for every alignment. Praying on an altar is in two ways different from praying somewhere else. First, if any potions of water are on the altar, the prayer is also a water prayer.