Why moving averages are used
Raw data can be noisy. A moving average reduces that noise by replacing each point with an average built from the most recent observations in the chosen window. The trade-off is lag: the more smoothing you apply, the slower the average reacts when the underlying series changes direction.
That trade-off is why the window length matters. A short window reacts faster but leaves more noise. A long window smooths more aggressively but can respond too slowly for fast-changing data.