Cameras and phones write information into the image file alongside the pixels. The most common standard is EXIF, and it can include the device make and model, the lens, shutter speed, aperture, ISO, the date and time the photo was taken, the editing software used, and, if location services were on, the GPS coordinates where you were standing.
That is useful for photographers comparing settings, and a privacy concern when you share photos of your home, children or workplace. Many social networks strip location data when you post, but email attachments, file-sharing links, messaging apps that send "original quality" files, and many websites keep it.