When we have single displacement reaction, one of the ions is simply swapping places with the other. For the first reaction, we have K which can become a cation so it will change places with the boron in the compound. When we do this, we have to look at the ions involved and determine what the subscripts will be in the new compound. If the cations have the same charge, then the formula will have the same subscripts but for this one, they will not.
When potassium forms a compound with oxygen, we have to look at the charges on the two ions to determine the subscripts.
Since O has a -2 charge, we need two K+ ions in order to create a neutral compound so we end up with K2O.
To write a balanced equation, we write the reaction
K + B2O3 --> B + K2O
and then add the appropriate coefficients to balance the reaction.
6K + 2B2O3 --> 4B + 3K2O