"gajni" comes from the English "to gain", and has more or less the same meaning as "to gain", i.e. it generally expresses the idea of receiving something. You can use it to translate "to win", especially in situations when you could replace "to win" by "to gain" in English. For example, you can say "gajni premion" for "to win a prize", as you can also say "to gain a prize".

When talking about winning a war, a battle or an election, one would usually use "venki" rather than "gajni". However, when used with a direct object, "venki" works like the verb "to defeat", i.e. the direct object is the person or army that was defeated. If you want to say "to win a war/battle/election", you should say "venki en milito/batalo/elekto". It is wrong to say "venki militon/batalon/elekton*".

There are also contexts where "venki" and "gajni" can be used more or less interchangeably. For example, "to win a sport contest" or "to win a lawsuit" can be either "venki en konkurso/proceso", "gajni en konkurso/proceso" or "gajni konkurson/proceson" (but not "venki konkurson/proceson"). If one is not actually receiving anything, the use of "gajni" in such context is somewhat metaphorical, but certainly acceptable.