A website can arbitrarily decide that it will not allow access to any person under 18. The minor violating the TOS in that case would bear whatever the legal consequences fall upon them, by being sued by the website owner.
For most if not all cases of so-called "18+" content, the restriction relates to laws regarding dissemination of obscene materials to minors. There are various state laws against disseminating obscene material to anyone, and additionally, federal laws against disseminating obscene materials to minors, see 47 USC 223(d). It is extremely unclear what constitutes "obscene" material (this is determined by the jury), so while porn may be legal, there is a risk in allowing a minor to view porn, because there is an increased risk that content that is deemed to be legal to show to an adult may be deemed obscene when shown to a minor. Out of an abundance of caution, a website operator may therefore try to filter out minors from the viewing audience.
Here is the logical flow of the relevant federal law. 1: A website cannot send obscene material to a minor. 2: Nor can they make it available for a minor to see. However, both provisions are subject to a "knowingly" provision, thus accidentally making obscene material available is not a violation of the law. Additionally, subsection (e)(5) provides defenses, one that the person
has taken, in good faith, reasonable, effective, and appropriate
actions under the circumstances to restrict or prevent access by
minors to a communication specified in such subsections, which may
involve any appropriate measures to restrict minors from such
communications, including any method which is feasible under available
technology
or
has restricted access to such communication by requiring use of a
verified credit card, debit account, adult access code, or adult
personal identification number
And furthermore, (6):
The Commission may describe measures which are reasonable, effective,
and appropriate to restrict access to prohibited communications under
subsection (d).
(The "Commission" is the FCC). There are apparently no such regulations.
There are related laws such as 18 USC 1470 which criminalize transferring obscene material to anyone under age 16, which also has a "knowingly" requirement. There are laws against tricking children into viewing "harmful" content by using misleading names, but the law also says that "a word or digital image that clearly indicates the sexual content of the site, such as 'sex' or 'porn', is not misleading".
In short, in a hypothetical cases where some content is labeled "18+", there are no legal consequences for the website operator unless the material is actually deemed to be obscene. In that case, the operator would have to make a reasonable attempt to exclude minors, such as by requiring a customer to be 18+ to view the site.