This is a rather broad ranging response to your post. Some time ago the Dean at York approached me about suggestions for what would be a fair distribution of faculty lines among the different departments at York that would take into account student interests as reflected in number of credits taken in various departments, number of majors in different departments and the fact that faculty "work" for teaching, say, a 3 credit course varies a lot. Computer science courses which teach a programming language and English courses which teach writing often have higher work loads than other courses with the same number of credits (or contact hours, which sometimes are not equal numbers). I was surprised that I could not find much of a "literature" on this issue, and I am not sure I was of much use to the Dean!
I think the CBMS reports, and the AMS has not only the most recent report available but earlier reports, too, are a very valuable resource in understanding statistical patterns for mathematics related educational issues. However, I want to point out that the CBMS report is generated using a stratified sample, and that over time the "definition" of what numbers go into the counts has changed. Some colleges have statistics degree programs within the mathematics department and some colleges have a separate statistics department. Some schools had one mathematics and CS department and now they have separate departments for mathematics and CS. So, I think one has to be somewhat careful with regard to time series data.
The graphic in your post is vague about where the data comes from (and whether two year college data is included) but in particular I want to call attention to the fact that when people refer to STEM, some include computer science in STEM and some, since there is no C (or CS) in the acronym, don't. And when data is collected about computer science one has to be careful what is included, since for many colleges there are information science degrees that are not computer science.
Until relatively recently (50 years ago), oversimplifying, people with mathematical talent majored in mathematics but now many such people have the choice of mathematics or computer science degrees, and many mathematically talented people also major in economics, physics, or engineering.
Trying to understand the trends is not easy.