The camera lens projects an image of the outside world onto the surface of the camera’s image sensor. During the exposure, this image is recorded. Mostly these images are tiny however image size is intertwined with object distance and image distance. Image size (magnification) increases with longer focal length lenses because the image distance (back focus distance) is lengthened. Perhaps you have worked with a movie or slide projector, if so, you know that the further away the projector to screen, the larger the image.
Your question relates to how lenses work. In short, they alter the direction travel of incoming light rays bending them inward (refraction). The image forming rays then depart the lens with a modified direction of travel.
The images that every lenses makes is flawed by seven (or more) defects we call aberrations. The lens maker strives to eliminate each by crafting the lens using multiple lens shaped to mitigate aberrations. A modern lens can be very good but aberrations are only minimized, they always deface, to some degree, the projected image.
One of these aberrations is called “chromatic aberration”. This aberration is due to the fact that the paths, through the lens, each color of light takes, will be slightly different. The shorter wavelengths of violet and blue are refracted (bent inward) to a great extent than the longer wavelengths of yellow and red. The result is, the actual focal length of the various colors is slightly different. What happens is, the violet image forms closer to the lens followed by blue, then green, then yellow, then orange then red. In other words, the projection distance for each color is different thus each image will be different as to size (magnification). The final image is a series of superimposing images of the various colors, red being the biggest image, violet the smallest image.
In a simple camera lens system (uncorrected for chromatic aberration) we can only focus on one color at a time, all the other colored images thus slightly out-of-focus. The lens maker strives to correct for chromatic aberration by making the camera lens a complex arrangement of different shaped lenses made using different types of glass. For chromatic aberration a strong convex lens is sandwiched to a weak concave lens. These differing lens shapes will tend to cancel chromatic aberration. No cigar, all we can do is mitigate, some residual chromatic aberration always remains. Better more expensive lenses do the best job.
What you are seeing is the residual effect of uncorrected chromatic aberrations. Your only remedy is to buy a better more corrected camera lens. However, we can improve this defect with high-end image editing software. Likely if you are using PhotoShop or one of its counterparts, look at the help section for advise as to how your software can cancel chromatic aberration.