Im in pain, distract me with science
There are 4 mechanisms of diarrhea. Osmotic, permeability increased, secreting and abnormal motility (peristaltic)
All of them can coexist, and in an inflammation, they usually do, but those are the mechanisms of diarrhea.
Specifically in regards to the virus, it probably will replicate in enterocytes (or some other intestinal cell depending on the virus). It will cause damage there, (decreasing the amount absorbed increasing osmotic pressure if it is in enterocytes [point 1]) and inflamation, increasing blood flow. This will increase the peristaltism [point 4]. In response to the infection, the immune system will respond secreting immunoglobulines and some other things point 3] and it will probably have some damage in the cells that will cause a "leakage" [point 2]. As there is more stuff in the lumen, that won't be absorbed (virus, inmunoglobulines...) there will be an increased osmotic pressure [point 1].
Certain viruses and bacteria have the ability to activate ion channels that are part of the normal mucosa in the gut. When these are constitutively activated you lose lots of electrolytes and with that, water osmotically follows causing the diarrhea and dehydration.
One of the best ways to explain this is to use cholera as an example. This isn't applicable for all cases but Its a good explanation of the general mechanism.
Cholera excretes toxins that irritate the intestines and cause chloride channels to open releasing a massive excess of chloride ions into the lumen of the small intestine. These ions lower the water potential inside the small intestine (Make the water less wet) so that more water from outside the small intestine moves into the intestine through osmosis so that the water potential inside and out is even.
However, this doesn't work too well in our bodies since very watery stool gets passed quickly and the whole situation gets reset. More chloride ions (now moving with its own concentration gradient because you left the excess behind in the toilet) and therefore more water, therefore more diarrhea.
Your body fixes this by removing the cholera preventing the chloride ions and therefore the rest of the steps.
Another fix that can aid It is Oral Rehydration Salts (dioralyte at the shops) and this has a specific water potential designed to help rehydrate your body and help break this cycle.
Whilst this doesn't apply to all causes it's quite a common mechanism and helps explain how the negative feedback loop can start leaving you to dehydrate and potentially die without your own body or medicine intervening.
Bacterial infections can cause diarrhea in a number of ways. Toxins, such as cholera toxin, can activate ion channels in your cells and this changes how water flows in your gut, just as u/brainonwheels has said. Cholera toxin activated a chloride channel that causes water to flow out of intestinal cells and into the intestines where it will dilute indigestible materials and leave the body as watery diarrhea.
Some bacteria can change the structure of the gut lining to change how water is absorbed in the intestines and, again, lead to watery diarrhea.
Viruses have even more ways to change gut structure that we are still beginning to understand. Rotavirus, for example, can affect how the nervous system affects intestinal cells, again causing changes to water flow in and out of the gut lining. Norovirus does not affect ion channels in the intestines but seems to change how fast the stomach moves food into the intestines. How norovirus does this at the cellular level is not entirely clear. However, it appears that the immune reaction to the virus causes inflammation of the intestinal lining, leading to decreased water absorption and diarrhea.
TL;DR: Anything that disrupts the normal function of the intestines and how the intestines can absorb water will cause diarrhea.