Because all PHP files are routed through index.php. If you want to hit your custom PHP script through web browser, you need to make an exception in .htaccess (for apache) or nginx configuration file.
If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue