Open up Ryzen Master and click on settings.
In the advanced box there should be an option for PROCHOT.
Make sure this is enabled.
If it's already enabled reset your bios, reenable your memory XMP profile and then don't overclock until you get a better cooler.
Either way you need a better cooler.
Your cooler can't cope with the heat output of the CPU.
The Ryzen CPU's will limit maximum boost frequency as temperature rises until it reaches a steady stat.
This is why the CPU is limiting itself to 4GHz under normal operation.