I understand how sliding window protocol makes the network reliable. But how can it control the flow of data?
Both sides of the conversation set the window size they're willing to allow. That by itself helps control flow. As one side gets congested with data it negotiates a smaller window, which slows things down. Congestion clears, it opens the window up again.
Congestion in this case is usually buffers on the receiving side of the data transfer, not actual network congestion en-route.