Python - A Regex Text File Searcher by Content Project
Documentation
&quot;&quot;&quot;
returns the directory if the path is a directory, and it exists otherwise asks to input again
&quot;&quot;&quot;

OK; but that's not what this function does at all. The &quot;asking to input again&quot; is done elsewhere.
Type hints
Guessing for this signature; type hints would remove the guesswork:
def format_output(matched_paths, matched_dict):

could become
def format_output(
    matched_paths: Iterable[str],
    matched_dict: Dict[
        str,
        Dict[str, str]
    ],
):

If this is true, the second type is complex enough that it could benefit from external declaration, i.e.
MatchesDict = Dict[
    str,
    Dict[str, str]
]

Dictionary iteration
for path in matched_paths:
    for line, matches in matched_dict[path].items():
        for match in matched_dict[path][line]:

should be
for path in matched_paths:
    for line, matches in matched_dict[path].items():
        for match in matches:

In other words, items gets you a key and a value; when you have the value, use it.
Logic inversion
I find that this:
    if re.search(string, path.read_text()):
        matched_dict[path] = dict()
        for i, line in enumerate(text_file.readlines()): # i refers to line number
            matches = list(re.finditer(string, line))
            if matches:
                matched_dict[path][i] = []

                for m in matches:
                    matched_dict[path][i].append(m.span())
        return True
    return False

is more legible as
    if not re.search(string, path.read_text()):
        return False

    matched_dict[path] = dict()
    for i, line in enumerate(text_file.readlines()): # i refers to line number
        matches = list(re.finditer(string, line))
        if matches:
            matched_dict[path][i] = []
             for m in matches:
                matched_dict[path][i].append(m.span())
    return True