Articifial mythology, or mythopoeia describes the devices in fiction, fantasy, or world building that can sometimes be quite parallel to our own. In the same vein as your examples, the Thursday Next series by Jasper Fforde is a parallel world of metafiction with worlds within worlds of alternate history where fantastic literary detectives police novels familiar to us without us even knowing it. Many chapters begin with quotes from their handbooks or histories which do not exist outside of these works of fiction.
Metafiction can be implicit or explicit, direct or indirect, and like a recent nod to the novel House of Leaves by Mark Z. Danielewski might break the fourth wall by addressing the reader or citing in-universe fictional works in footnotes.
Lexico gives metafiction as:
Fiction in which the author self-consciously alludes to the
artificiality or literariness of a work by parodying or departing from
novelistic conventions and traditional narrative techniques.
And Wikipedia adds:
While all metafiction somehow deals with the medial quality of fiction or narrative and is thus generally media-centred, in some cases there is an additional focus on the truthfulness or inventedness (fictionality) of a text, which merits mention as a specific form. The suggestion of a story being authentic (a device frequently used in realistic fiction) would be an example of (non-critical) truth-centred metafiction.
Rather than commenting on the text, implicit metafiction foregrounds the medium or its status as an artefact through various, for example disruptive, techniques such as metalepsis. It relies more than other forms of metafiction on the reader's ability to recognize these devices in order to evoke a metafictional reading. Implicit metafiction is described as a mode of showing.
Mythopoeia is defined as: (Wikipedia)
a narrative genre in modern literature and film where a fictional or artificial mythology is created by the writer of prose or other fiction.
Works of mythopoeia are often categorized as fantasy or science fiction but fill a niche for mythology in the modern world, according to Joseph Campbell, a famous student of world mythology.
Mythopoeia is sometimes called artificial mythology, which emphasizes that it did not evolve naturally and is an artifice comparable with artificial language, so should not be taken seriously as mythology.
Further reading on metafiction from Oxford Research Encyclopedia:
Metafiction is a style of prose narrative in which attention is directed to the process of fictive composition. The most obvious example of a metafictive work is a novel about a novelist writing a novel, with the protagonist sharing the name of the creator and each book having the same title.