Whenever you are spotted by a guard doing something you shouldn't be doing you will accumulate guard heat. Guard heat for example can be accumulated for being caught in restricted areas such as other inmates cells or not being in the dining room at meal times.
The amount of guard heat you accumlate for infractions will depend on the prison you are playing, the easier prisons you will accumulate much less guard heat.
Over time your guard heat will slowly decline and whenever you sleep in your bed at night it will reset to 0. If you let your guard heat reach 89% the guards will attack you on sight and if you are outside in the prison grounds during the day when this happens the snipers will fire at you and each shot that hits will deal 20 damage.
In order to stop the guards attacking you when your guard heat has reached 89% you must run away and try and lose them. This is achieved by running around until the guards disappear from your screen. As soon as you have lost the guards you will be able to go about your business again but make sure you avoid the guards until your guard heat drops below 89%.