As you suggest in your question, it's a figure of speech
(namely, why specifically did the Torah choose to use the example of a burglar "tunneling in")
In his commentary to Exodus 22:1 -- the verse about a robber found "tunneling in" -- Rashi writes:
אֵין זוֹ רְצִיחָה, הֲרֵי הוּא כְמֵת מֵעִקָּרוֹ
This is not regarded as a murder; it is as though he (the thief) has been dead from the beginning of his criminal act
This is to teach us that the burglar came with the intention of killing you, for the burglar knew that a person wouldn't sit idly by while their property is being stolen.
Rashi continues- thus the Torah teaches us the rule:
"אִם בָּא לְהָרְגְּךָ, הַשְׁכֵּם לְהָרְגוֹ"
“If one comes with the intention of killing you, be quick and kill him.”
Further proof
The very next verse (Exodus 22:2) which is a continuation of the robber who "tunneled in" states:
אִם־זָרְחָ֥ה הַשֶּׁ֛מֶשׁ עָלָ֖יו דָּמִ֣ים ל֑וֹ שַׁלֵּ֣ם יְשַׁלֵּ֔ם אִם־אֵ֣ין ל֔וֹ וְנִמְכַּ֖ר בִּגְנֵבָתֽוֹ׃
If the sun has risen on him, there is bloodguilt in that case.—He must make restitution; if he lacks the means, he shall be sold for his theft.
To which Rashi explicitly writes:
אֵין זֶה אֶלָּא כְמִין מָשָׁל: אִם בָּרוּר לְךָ הַדָּבָר שֶׁיֵּשׁ לוֹ שָׁלוֹם עִמְּךָ
This is only a metaphorical expression: if the fact is clear to you that he is peaceably disposed towards you.
See also:
Sanhedrin 72a-b which discusses this topic extensively, as well as Rambam Hilchos Geneivah 9:7-13