Did you try Safe Mode?
How to use safe mode on your Mac - Apple Support
That can help eliminate some third-party interferences. If the computer gives you a stable Desktop in Safe Mode, don't use the computer but let it sit in Safe Mode boot for a half-hour or so. Then try a normal boot.
If that doesn't help, you probaly need professions help.
And that bring up a very important point: the AGE of your computer, which we do not know. If it is too old, Apple will not service it and you end up lugging a heavy computer to an Apple Store to be told "Sorry."
So what the the year model of your iMac? As it will not start, you can get the important sub-model from the serial number, which is on the bottom of the "foot" on most modern iMacs:
Plug your serial number into this Apple support page:
Check Your Service and Support Coverage - Apple Support
The return will include the sub-model name we need:
In this example, "27-inch, Mid 2010" is the sub-model. Please tell us the sub-model BUT DO NOT POST THE SERIAL NUMBER for security reasons.
If the computer is too old, Apple may not find it. In that case, this third-party site offers the same function but works on older models:
https://everymac.com/ultimate-mac-lookup/
Remember that iMacs have been in continuous production since 1998 (!) in hundreds of variants, so getting effective and specific help in a forum where your fellow end users can neither see nor remotely access your computer requires a lot of "up front" details from you.