In the case of the latter, only a very small subset of people who get Epstein-Barr go on to develop MS.
Maybe your viral infection caused your immune system to produce antibodies that happened to bind to gluten along with the viral proteins they were designed for.
This is kind of a crackpot theory, but I wonder if it could explain your experience:
Novel viral infections trigger the formation of new kinds of antibodies. We have strong evidence that some viruses can trigger the formation of antibodies that bind to human cells in addition to those of the virus. Two examples of this are bites from the Lone Star Tick causing red meat allergies and the Epstein-Barr virus causing multiple sclerosis.
In the case of the latter, only a very small subset of people who get Epstein-Barr go on to develop MS.
Maybe your viral infection caused your immune system to produce antibodies that happened to bind to gluten along with the viral proteins they were designed for.