Aukxn: Whole book chapters have been written to answer your questions. Briefly, in the window design method of designing FIR filters we define our desired freq response using $N+1$ freq-domain samples. Next, we inverse DFT those freq-domain samples to obtain the time-domain impulse samples. But dead DSP pioneers plowed through the algebra to develop equations (for simple filters like lowpass, highpass, bandpass, etc.) that define our impulse response samples without needing to perform inverse DFTs. Those equations are the $h_d[n]$ expressions in mikroe's Table 2-2-1.
Using mikroe's definition that a FIR filter has $N+1$ taps, you decide the value of $N+1$ and then use his appropriate equation to compute a finite-length $h_d[n]$ imp response sequence. Now, performing the DFT on the finite-length $h_d[n]$ sequence will show that its freq response now has potentially undesirable ripples in its passband and the stopband attenuation may not be as high as you'd like. If you cannot tolerate the passband ripples and possibly poor stopband attenuation what can you do?
What you do is window the $h_d[n]$ samples, by multiplying them by some window sequence. The freq response of the windowed $h_d[n]$ imp response samples, $h[n]$, will have drastically reduced passband ripples. But the problem now is, the new filter's freq-domain transition region's sharpness will be degraded by the windowing operation. You can solve that problem by increasing the value of $N+1$. That is, use more taps. So YOU have to decide which is more important to you, reduced passband ripple and improved stopband attenuation or reduced number of taps. That's your decision. And filter designers experiment with various window sequences to help themselves make that decision.
By the way, using a rectangular window means not modifying the $h_d[n]$ samples, produced by mikroe's equations, in any way. Rectangular windows have the worst passband ripple and poorest stopband attenuation but have the sharpest freq-domain transition region. mikroe used a rectangular window in his '188.8.131.52 Example 4' because that's what the voices in his head told him to do.
As for the $M$ in mikroe's equations: the dead DSP pioneers developed two forms for their $h_d[n]$ equations depending on whether they; (1) wanted their $n$ time index to go from a negative integer value to a positive integer value, or (2) wanted their $n$ time index to go from zero to a positive integer value. In the first case there is no $M$ variable in the $h_d[n]$ equations. In the second case there is an $M$ variable in the $h_d[n]$ equations. It's a matter of preference and mikroe, as well as I, preferred the second case. All that I've written here is in the standard DSP textbooks.