If you want to auto-indent after hitting Enter, make sure to enable Smart indent on enter under Settings | Editor | General | Typing Assistance.
If you are pasting a code snippet, you might want to configure Auto-format on Paste in the same Typing Assistance settings section (with value Indent if you do not want to reformat the snippet completely and only indent it)