Why does Drupal use strange file extension for PHP code?
Because it's easier for the core to know about special files that way.

As a developer you're free to name your module or theme whatever you like, so that means that Drupal core needs another way to find and identify certain important files.  Doing this using the file extension is an easy way.