"Markup" is the generic noun for annotations added to a text, whether done with a pencil or with various electronic means, and whether or not they have anything to do with formatting. Even readers' underlines can be called "markup".
The corresponding verb is "to mark up".
"Formatting" refers specifically to arranging parts of a document into pages or screens. When you make your window narrower, the document gets "reformatted", but none of the "markup" changes at all.
"Markup" originally involved annotating several kinds of things on paper: spelling or other corrections; things like breaking a paragraph in half or adding a heading; and giving formatting instructions such as to set a portion in italics.
In modern publishing those tasks are commonly separated:
An author or "encoder" identifies parts of a document by "what they are" (this bit is a footnote, 2nd-level heading, bibliography entry,
list item, command name, etc). This is called "descriptive" or
Someone decides how each kind of thing should be formatted in a print or online edition. Publishers call this their "house style" or similar names.
Some person or program then applies the design to the objects, via "formatting" and "typesetting".
Computer-based document systems progressed similarly: Many early ones had commands only for formatting effects: "change font", "shift left margin", "switch to bold", "skip a line", etc. Of course, similar combinations are used over and over again, so systems soon provided named sets of instructions for the common kinds of things.
Eventually (starting with Brian Reid's "Scribe" system), systems began to allow authors to ignore the "how" of formatting almost completely, by just picking "kinds" (often called "styles"). Many authors just do this, while many others do manual formatting, especially for short documents.
"Markup" is ubiquitous, but "formatting" isn't always part of the picture at all. Visually impaired readers may use a screen reader, and objects such as "heading", "footnote" etc. are communicated in entirely different ways. Similarly, a search engine cares little about fonts, but may care a great deal about which parts are the document title, author name, or bibliography.