That's the intented behaviour in mac os. You select the window, then you can interact with it. That way there's no more trying to select a window, then you accidentally delete all your lifes work or something.
This stems from Mac OS being designed for you to just pile windows on top of each other. If you're constantly selecting different windows you'd have yo be careful where you click.