A bit hard to follow exactly what you want as an output but,
This gives the Number of records for each month in a given year
SELECT Month(MDate) as MM, COUNT(*) MON
FROM My_Table
WHERE year(MDate)= 2023
GROUP BY Month(MDate)
This gives the number of months that have an least one record in it for a given year
SELECT count(distinct Month(MDate)) as MM
FROM My_Table
WHERE year(MDate)= 2023