Minecraft, sprint key
Solution 1:
As other answers have stated, by simply pressing the L-CTRL you can start sprinting without having to worry about the awkward "double-w" key function.
As for why this is happening, it's a likely possibility that there is an occasional latency between server and client, which causes a loss of input, and therefore, you stop sprinting. Unfortunately, there isn't too much that can be done about this, especially if you're not the only one experiencing this.
However, if you can boost the speed of your network in any way, this may help - switch from Wi-Fi to Ethernet, or perhaps upgrade your network plan.