I keep on having glitches with my Mac, and then after it freezes with 3 beeps.I have to press the power button for about 8 seconds before it stops. Sometime it turns on back, sometimes it doesnt. What could be the cause of this problem?? My Mac is 2012
An intermittent issue like that could be as simple as broken wires, or cracked internal connectors, that make/break connection, which causes the unit to sometimes work, sometimes fail.
It would be prudent to send the unit in for repairs by Apple, and hopefully you have a Time Machine backup of your system.
Three beeps when you start your mac are indications of RAM issues.
You can look up your specific manual at http://apple.com/support/manuals to see if the RAM is user serviceable. If so, you can try swapping the chips, reseating them or testing with just one chip in each slot.
If the RAM isn't user serviceable, you'll likely need to get the files backed up and then in for repair or replacement.