Amplifier Screech at High Volume
What you're hearing is FEEDBACK caused by the nearness of the guitar to the amplifier speaker. Always mute it when not in use, or don't move it close to the guitar amplifier speaker when unmuted.
Usually, even though you hear a high-pitched screech, the problem is actually caused by low frequencies, sometimes below the human hearing threshhold (i.e., subsonic) because they are more omnidirectional and thus more easily easily can loop between input (the guitar pickup, especially on a hollow-body guitar) and output (the speaker). The screech frequency is determined by the distance between input and output, determining how quickly the output reaches the input (then loops around through the amplifier). Therefore, reducing the BASS a bit will often alleviate some of the problem.
This is basically the same type of feedback heard when a microphone is turned up too loudly or the mic is pointed at the PA speaker. Avoid those actions and your feedback will be minimized.
Only time and experience will allow you to automatically take actions to avoid feedback. I worked in the San Francisco Bay Area as a manager and sound man for rock bands and several nightclubs for 22 years. My college major was Physics (which includes acoustics).
Keep on rockin'!