Hi, imedicineman,
and welcome to the Apple (user-to-user) Community!
Re: "Messages in iMessage app not working on mac book pro"
"The login screen asks for my Apple ID either phone number or email. I have tried both.".
You would need to use the same Apple ID Account Log-in and password that you use across devices.
Re: "The messages come up on the screen and remain for only 3-5 seconds ...."
Seems you are using MacOS Monterey 12.7 on your MacBook Pro. There have been security updates available for download from time to time since then:
See Apple support's online article: What's new in the updates for macOS Monterey - Apple Support
Eg: says: macOS Monterey 12.7.6 is the latest
"This update provides important security fixes and is recommended for all users."
_______________________________________________________________________________________________
Re: " ..... the login screen reappears and asks again and again and again".
_____________________________________
If you haven't updated yourMacOS to 12.7.6, it is likely you may need the added security on your Mac to log-in and send and receive Messages securely.
You can check for updates in System Settings > General > Software Updates.
NB: It is always wise to securely back-up your Mac's data, before updating.
________________________________
If you are already using MacOS 12.7.6: you may want to try restarting your Mac: eg: Apple menu > Restart
(Restarting deletes temporary files, re-establishes connections, may update recent setting changes, and often restores order if something is not working as expected.)
________
If needed: You could check through: Set up Messages on Mac - Apple Support for tips (for MacOS 12 / Monterey)
or
Apple's Messages Support webpage (info. / support / contact options etc.)
Messages for iPhone, iPad, Apple Watch, and Mac - Official Apple Support
All the best :-)