The theories for how gut-brain axis modulation works include altering the balance of nutrients that get absorbed and modulating the vagus nerve, primarily. For someone with autism it might be possible that altering some of these balances could make the condition better or worse, but that’s all theory without much foundation.
What is known, however, is that diet has a massive impact on the microbiome. Even the mechanism for that is obvious: Bacteria thrive on different foods, so if you eat more of one class of nutrients and less of another then the microbiome proportions will adjust based on which ones thrive on that diet.