This is probably a (biased) extract from a study like this (Hippisley-Cox et al.), that did look at age groups specifically:
Subgroup analyses by age showed that the increased risk of events associated with the two mRNA vaccines was present only in those aged under 40 years. For this age group, we estimated 2 (95% CI 1, 3) and 8 (95%CI 4, 9) excess cases of myocarditis per 1 million people receiving a first dose of BNT162b2 and mRNA-1273, respectively, and 3 (95% CI 2, 4) and 15 (95%CI 12, 16) excess cases of myocarditis per 1 million people receiving a second dose of BNT162b2 and mRNA-1273, respectively. This compares with ten (95% CI 7, 11) extra cases of myocarditis following a SARS-CoV-2 positive test in those aged under 40 years.
So yeah, one the two mRNA vaccines (Moderna, which had higher dose of the spike) did exhibit slightly higher myocarditis rate on the 2nd dose than actual infection (12-16 vs 7-11) but the other mRNA vaccine (Pfizer) had lower, non-overlapping reports (2-4) even on the 2nd dose. So quite possibly there's dose-dependent response, and the average infection [in that study] released less of the spike than the Moderna vaccine.
(I should say that I found this study in part because the original Q, before it was edited with the actual quote, only mentioned the Moderna vaccine.)
But the Q-quoted claim that "numerous studies have suggested that this is on the order of 20 to 50 times greater" seems far off based on this study.
As for the other answer, in fact the Danish study separately looked at infections (aside from vaccine vs unvaccinated). And for the former:
In comparative analyses of outcomes within 28 days of a positive SARS-CoV-2 test (tables S17-S19 and fig S5), SARS-CoV-2 infection was associated with an adjusted hazard ratio of 2.09 (95% confidence interval 0.52 to 8.47) for myocarditis or myopericarditis, but our statistical precision was limited."
This is actually higher that what they found for vaccine overall "adjusted hazard ratio 1.34 (95% confidence interval 0.90 to 2.00)", but the intervals are overlapping. Alas the infection results are not broken down by age in that piece due to not enough observations, which also caused the fairly large confidence interval for the infected (even straddling 1). They basically observed 3 people infected (table S18.)
There are some other studies that similarly found that myocarditis risk was higher after Moderna compared to Pfizer, and that this difference was more pronounced in young males--one study reported "aOR: 5.09; 95% CI: 2.68-9.66" for that age and sex group (Moderna vs. Pfizer). OTOH other studies didn't find such a difference between the two mRNA vaccines. FWTW, there's one study from France that found a RR as high as 44 (95%CI 22-88) for the Moderna vaccine in the under 24 male group, and also as high as 41 (95%CI 12-140) for females in the same age group--the latter finding is a bit at odds with most other studies; their Pfizer numbers for the same groups are
13 (95%CI 9.2-19) and 9.6 (4.3-22) for males and females, respectively. The Moderna vaccine was much less used in France though, so the raw counts that drive these results (which also have a fairly large range) are substantially smaller for Moderna, about 10 times fewer--see their table S2). A US study (Kaiser) that was specifically limited to those under 39 y.o. also found a difference between the two vaccines, but considerably smaller "In head-to-head comparisons 0–7 days after either dose, risk was moderately higher after mRNA-1273 than after BNT162b2 (RR: 1.61, CI 1.02–2.54)."
But most of these studies (including the one from France) generally don't have an (naturally) infected arm, so they're not that useful for the Q at hand here.
Also, risks (for either vaccine) don't seem to increase on a 3rd/booster dose those; that result has been replicated separately in another study that only looked at the Pfizer booster.