Well, moving averages here have not been shifted to the right, but instead they have not been calculated for the initial period of the SMA. Say, we are calculating a 30-day SMA for price - since, for the first 30 days, we don't have 30 points to calculate moving average on, it is difficult to calculate SMA in that period, which is why these periods have been omitted from the graph.
If you look closely, you will see that the ends align for the actual data and their SMA vs a shift.
You are, for example, assigning the average for the first 30 days to the 30th day in the graph. It works better if you assign it to the 15th day instead. Try it and you will see the graphs line up nicely instead of the SMA graph having a 15 day lag.
Well, SMAs are meant to be assigned like the way I did. We may get a better picture by assigning them to the middle of the observed period, but in that case it is a false picture. Consider this, we are mixing past values with the future values once you assign them to the 15th day. Do we know the future at any time?
Hence, SMAs represent the moving average over the last `n-1` days and the current day.