Black lines on my Macbook pro screen 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.