Maybe you're seeing photos in which the camera/scope was aimed at a galaxy but nearby stars (relatively speaking) were captured in the image frame. See this picture of M31 for example:
http://antwrp.gsfc.nasa.gov/apod/ima...M31_hallas.jpg
Any individual star in that image lies within the Milky Way and between the camera and M31. An individual star sitting about 1 million light years away (roughly half the distance to M31) would be difficult to resolve in an image although maybe not impossible; Edwin Hubble was able to resolve Cepheid variable stars within M31, which helped him to calculate the distance between the Milky Way and M31. Still there are darn few stars in that big void between us and M31.
As damian1727 said, stars can be flung from a galaxy, such as when two galaxies collide.
For fun, google the phrase "star formation between galaxies".