Mechanics and Lore are not defined game terms, but it may be useful to think of lore as what the characters could know
What is "Lore"?
Any of the many mentions of "lore" in the PHB either refers to lore that the player characters or other characters in the game may know, study, etc, or is part of a feature or spell name. There is nothing that states lore is a certain kind of rules text. It is the same in other rules material, wether the DMG, MM, Xanathar's Guide to Everything, Tasha's Cauldon of Everything: Lore always is used as something in-game, that the characters know about, or in some cases in the names of class features or spells, but never in the sense of "a special kind of rules text".
People have hypothesized that "rules text" is player-facing, and "lore" is both player-facing and character-facing, which I think is a useful way to think about it. That would make what we think of as mechanics the part of the rules that is only player-facing. But it is never defined like that by the rules themselves. This use of the terms is something the community came up with, not a rule.
What are "Mechanics"?
While the PHB has zero mentions of the term "mechanics", the DMG has two mentions of the term, one time under Creating New Class Options (p. 288):
It's perfectly acceptable for two class options to have similar features, and it's also fine to look at other classes for examples of mechanics
you can draw on for inspiration.
The other time under Character Backgrounds (p. 289)
A well-crafted background (...) helps define the character's place in the world, rather than what a character is in terms of game mechanics.
There is no explicit definition what constitutes game mechanics and what not, so we are back to using the dictionary definition for mechanics: "the machinery or working parts of something".
It seems the two snippets that use the term (and there are a couple more in Xanathar's, that use it in the same way) talk about the machinery of game rules, of how the game works. The characters however have no idea that they are constructs in a game, so this must be the parts of the text that the characters would not know about.
For example, this could include things like1:
- Dice rolls (as mentioned in several other answers)
- Points or levels (experience points, hit points, exhaustion levels, class levels etc.)
- Time resolution in combat (inititive, rounds, turns, actions and action types)
- Artifacts of the game like stat blocks and character sheets
Separating Lore form Mechanics
Since all text is rules, it is hard to separate "lore" from mechanics, even if you consider lore as something the characters would be able to think about.
For example, assume you wanted to declare the write-up about the background of the race that introduces the race and its place in the world as lore, and the "Traits" section of each race as what one could think of the race's mechanics.
However, even this narrow view of mechanics has issues: many, if not all of the traits will have an expression that the characters can think about. Take the first one in the core rules, (I'll use Dwarf, like Anne's answer):
Ability Score Increase. Your Constitution score increases by 2.
The player characters do not know about constitution scores, or that they have a score that increases by 2. But they will know that dwarves tend to be especially tough and hardy. This makes it essentially impossible to separate mechanics from lore by marking certain sections or paragraphs of the text as "mechanics" or "lore" -- the very same feature and sentence carries elements of both.
It's the same for Age: the introductory text says "Dwarves can live to be more than 400 years old,", and the Traits section then defines:
Age. Dwarves mature at the same rate as humans, but they’re considered young until they reach the age of 50. On average, they live about 350 years.
Is the write up lore, and the trait mechanics? A dwarf would also know that young dwarves come of age around 50 years, and typically live to 350, with the one living over 400 years being especially long-lived.
So, I think there is no defined rules on what would be what, and it also makes no sense to try to separate it by text section. Try to separate it by what the characters would be able to think about, if you feel the need to separate it.
1 Some other rules implementations like movement and squeezing rules, or resting and resetting limited use abilities create sharp cut-offs instead of a more gradual experience like in the real world. These do have observable outcomes for characters, and this often causes questions about how to explain them in game. Other examples would be the implementation falling, or of darkness as heavy obscurement, where rules mechanics and real-world expectations differ.
I think these examples show how hard and maybe in the end futile it is to try and cleanly separate "mechanics" from "lore" -- because these have observable effects, we hush them up, overrule them, or allow their effects to be knowable lore, to not disrupt immersion in the game.