Entering a child page that does not exist will redirect to the image attachment page, specifically, the image attachment with the same slug.
example.com/cars/volvo-car/ will redirect to the image attachment page with the URL
volvo-car image attachment's permalink reflects the image name on initial upload, but even after I changed the attachment's slug to something different like
volvo-car-image the non-existent child page still redirects to it instead of firing the 404 error page.
I can't find any entries in the database that would cause the redirect. I also tried it with different websites on different servers, but still getting the same behavior.
How can I fix it or stop WordPress from doing it?
Another thing I have discovered is that the parent page doesn't have to exist before this happens. As long as you add the image attachment URL's slug after the parent slug, it would still redirect to the attachment page like