By default, IntelliJ IDEA allows you to click any where on the editor and type. Some users find it annoying. If you are new to IntelliJ, you may find it a bit difficult to change the setting. This is available in the Virtual Space section of Editor Settings in IDEA preferences.
Turn it of by going to File menu -> Settings -> Editor -> Virtual Space and uncheck ‘Allow placement of caret after end of line’.

Peace of mind.

Here is a bonus video of how it is done.