To start with, src/main/java does not seem to be marked as sources root in neither of the pictures. Notice the small red dot on your App.java file? That should be a “Class symbol” if your project is correctly set up.
To fix this, right click the src/main/java folder and choose Mark directory as -> Sources Root. Your project structure should now look like this:
When it comes to the difference between your two screenshots, it is nothing but a difference in the presentation. There is something called Title Bar Context Menu (the small cogwheel above the folder structure) which lets you customize its behaviour.
The second of your screenshot seems to have the Flatten Packages option set, which forces empty packages to be “flattened”:
Once again, this is just plain presentation. There is not a com.example folder on the disk, but two folders com/example.
Without the Flatten Packages option, the structure would look like my first screenshot.
So again, it is really just a presentation issue. Exactly why you experience different behaviours when creating new projects is hard to say without more context, but simply use the Title Bar Context Menu to customize the look to be as you want. These settings are saved in your .idea folder per project.
CLICK HERE to find out more related problems solutions.