Nucleotides contain phosphorus (P), so 32P labels the DNA core of the phage.
Some amino acids contain sulfur (S), so 35S labels the protein coat. Differently labeled phages are used to infect unlabeled bacteria.