Seemingly on random but almost always when opening an application this strange rectangle shows up in the upper right corner of my screen. It is the same porportion and colour as the colour test screen you see when booting up but it is kind of see through and fades quickly. I don't know why or what this is and i would be gratful of any help you can give.
Your power supply isn't supplying the correct voltage. See this link.
You can override this though by editing your config.txt file if you understand the risks:
avoid_warnings=1 #removes the warning overlay. avoid_warnings=2 #additionally allows turbo when low-voltage is present.
If you ever have a red square at the top of your screen, this indicates that your CPU is too hot. The rainbow square indicates that you aren't getting enough voltage into the Raspberry Pi.