=MID(text, start_num, num_chars) returns num_chars characters starting at position start_num. Positions count from 1: in "INV-2026-0042", the year starts at position 5, so MID(A2,5,4) is 2026.
If the start is past the end of the text, MID returns empty text, not an error. If num_chars runs past the end, it just stops at the end, so a large number like 100 means "to the end".
Fixed positions only work when every value has the same layout. When the piece you want follows a character like a dash or an @, find that character's position with FIND or SEARCH (next lesson) and feed it to MID.