Ask your DM
You have cited the only rules related to "loose earth" in your question. No further details are given in the spell or in any other rules. When a term is not defined in the rules, it defaults to its idiomatic meaning, which does give us something to go on.
Specifically the word "loose" here implies that this is not solid, restrained, or compacted "earth".
So the answer to
Digging a 10 ft hole in solid stone
Is clearly "no". Stone is not at all loose and would thus not fit the definition.
Jeremy Crawford has also agreed with this assessment with this clarification:
Think dirt, not stone.
On the flip side the answer to
Top soil of a recently plowed field
is clearly "yes". I can't imagine a better example of the idea of "loose earth" than recently tilled soil.
But there is where the clear answers end. All your other examples are going to vary based on how your DM interprets the phrase. How loose does earth need to be to be loose? Can it contain soil and small rocks? Clay?
Only your DM can answer these; the rules give no further guidance.
Example: Foundation of a building
Since you are specifically interested in this use case I will address this directly (even though the answer is the same as the above).
Digging a 10 ft hole under the foundation of a building
There are questions here that are dependent not only on DM interpretation, but the precise situation as well. What material is the building built on? Is it built on solid rock? Loam? Swamp? Is this a massive stone castle or a small wooden shed (which changes how "loose" the stuff under the building is)?
None of these questions are answered by the rules. They are thus left up to the DM.
This is one of the ways 5e is specifically designed. Instead of writing precise definitions to have to account for all the possibilities of using the spell they left it vague so the DM could decide on the most fun interpretation for their group.