To prepare nutrient agar, the ingredients (peptone, beef extract, sodium chloride, and agar) are dissolved in distilled water and the solution is sterilized by autoclaving. Once sterilized, the medium is poured into petri dishes and allowed to solidify. This preparation ensures a sterile environment for culturing microorganisms, minimizing the risk of contamination.