I have just installed WordPress locally in my computer and run the website successfully.
I want to achieve following: when logged-in user tries to access wp-login.php or register page, it should be automatically redirected to home page.

I have spent several hours on web, but could no come up with solution neither was I able to find appropriate WordPress plugin.

My question is: why does WordPress function this way? how can we change this behavior as natively as simply as possible?

Thank you