You can't ensure a specific version 3.9.6 with brew package python@3.9. Homebrew is a package manage designed to get latest pacakge. python@3.9 will be kept updating to the latest patch version 3.9.x.
If you REALLY to stick with specific python version, choose conda (miniconda is preferred) or pyenv.
How to setup Python 3.9.2 Default - Apple Community
installation - how to install python 3.9.6 using homebrew on Mac m1 - Stack Overflow
How To Install Python 3.9 On Mac
No idea how Python (3.9) was installed on mac, brew can't find Python and there's no app drawer icon
I wish mac had an uninstall utility like windows that showed all programs on windows regardless of how they were installed.
Today I wanted to upgrade python, which for some reason automatically works even though I don't remember ever installing it. Maybe VSCode installed it itself? No idea. In any case I saw that it was an older version so I tried upgrading, I couldn't find a command from within Python to upgrade itself so I tried brew, but brew can't find python (or python3) so I looked for it in the apps. Not there.
I tried using the GUI installer hoping it'd find its own previous version like what happens in windows, and offer to upgrade.
Also I'm not sure where "python" has disappeared now, it seems to have cleared the path and replaced it with a python3 so on the terminal doing "python --version" no longer outputs 3.9.x but instead says not found, while a python3 --version command now works and outputs 3.12.