Does net exports has to do with borrowing and lending?
Maybe this will help: imagine that trade is done in the currency of the foreign country.
Suppose you are American, you are standing on the border of Mexico, and you sell a hot dog to a Mexican for 20 pesos. Now you want to buy tacos from him, but you want 30 pesos of tacos. So he lends you 10 pesos, then you buy the tacos.
So X=20, M=30, and net exports= -10 and you borrowed 10.
Side note: some poor, risky countries (e.g. North Korea) can't have negative net exports, because no one will lend to them.