The simple and obvious answer is that it all depends on the position of black's pawns and king. In general the further up the board the pawns the better for black provided the king is in contact with the pawns, preferably in front of them.
Worth pointing out that the position you give is winning for white because the pawns aren't far enough forward. From ...
First of all, White wins in the diagram you provide, although it's not obvious at a glance how. White plays Qf2 first to stop the king from advancing. Black can't just sit there forever because the White king will eventually eat that a-pawn and come back, so they have to play h4, and then another pawn move. If Black plays g3, White responds with Qf3, and now ...
You were playing the chess variant called Crazyhouse. In this variant you can place pieces you captured, as one of your color anywhere on the board, instead of a normal move.
I don't know the software you are using, but on Lichess the variant can be selected in the "Create a game" dialog. There should be something similar in your application.
It is called a clearance sacrifice:
In a clearance sacrifice, the sacrificing player aims to vacate the
square the sacrificed piece stood on, either to open up lines for his
own pieces, or to put another, more useful piece on the same square.
There is no specific word for a gambit that does that to open files to then win.
It would be the result of a general "gambit" giving up a pawn.
I note that you said lose a pawn unintentionally and then win.
That is not a gambit that is two beginners playing like beginners.
If you have a material advantage, do not play as if it in itself guarantees a win. Act aggressively and seek an active plan. This principle is often violated especially by less aggressive chess players, who often stop active play, having achieved a material advantage, believing that it will automatically lead to victory. This is not the case, and as a ...
Michael Stean, in his "Simple chess" introduced the idea of the "capacity" of a given Pawn structure. How many pieces can live inside it without getting in each others way. If your opponents pawns do not have enough capacity for his pieces, he will have difficulty manoeuvering them to defend. This introduces the "principle of two ...
b4 fixes the black pawns a to c, because they cannot advance without support.
In the original position, 1. b4 would not fix the pawns. Black could play ...b6 followed by ...c5 at the right moment. After 2. ...a6, ...b6 is not possible anymore without support. And without ...b6, ...c5 is not possible. So the black pawns need support by their King or Rook to ...
Opening a file for your rooks is one good reason to play a pawn break. Although, you should make sure that opening that file doesn't help your opponent's pieces more than it helps yours. As for breaking through near your most advanced pawn, this isn't really a rule that has to be followed closely. But the idea behind it is that once your advanced pawn ...
The only reason is that you gain an advantage by doing it.
In some cases it is just to avoid losing advantage.
Pawns diagonally across from each other are NOT a break.
Breaks come when you take pawns or push a pawn where it can take two others if they do not capture your pawn.