How does salmonella get into eggs?
There are two basic mechanisms:


the salmonella is on the shell and when the egg gets broken the interior gets contaminated; or
the chicken's reproductive system is contaminated and lays an egg with contaminated interior.


To reduce the very common (a few percent) shell contamination, eggs sold commercially have their shells treated (typically washed). After washing only about 50 in every million eggs will still have some shell contamination. The shell contamination may have been there when the chicken laid the egg, from fecal matter, or as a result of plant processing.    

In some rare cases the surface salmonella can make it to the inside without breaking the egg: if it was there while the cuticle dried, if the egg is stored at room temperature, or if the environment is moist.