This is likely to be a mini cycle due to the fact you changed the substrate.
What you have to remember is that the beneficial bacteria that deals with ammonia and nitrite lives everywhere in the aquarium, not just in the filter.
By removing the substrate, you are removing a lot of bb at the same time.
And thus the bb has to recolonise your make up the numbers that have been lost, THIS is the mini cycle and this is why you’re seeing a bacterial bloom which is a good sign of this occurring.
Nothing to be unduly alarmed about.
First, keep an eye on your water parameters over the next few days and do a large water change of at least 50% when you see a reading of ammonia or nitrite being anything other than zero.
Second, the bloom will go away on its own after a day or three and will not harm anything at all.
It won’t take long for the tank to get back to normal levels and generally speaking your betta will be fine but do keep an eye on your ammonia and nitrite levels.