The long border is due to the Burmese control of the Tenasserim Coast (also known as Tanintharyi), the region between the border and the Andaman Sea. The predecessors of both countries have fought numerous wars over the coast. If you look at the Wikipedia list of Burmese–Siamese wars, many of the wars had the conquest or defence of the coast as their main goal.
The current border was the result of two wars at the late 18th century. The Burmese Konbaung dynasty captured the northern half of the territory in 1760 and then the rest in 1765-67. As you have guessed, the territory were contested in subsequent wars, but neither country managed to gain territory on this front. As Wikipedia puts it,
In the following decades, both sides tried to extend the line of
control to their advantage but they both failed. The Burmese used
Tanintharyi as a forward base to launch several unsuccessful invasions
of Siam (1775–1776; 1785–1786; 1809–1812); the Siamese too were
unsuccessful in their attempts to retake Tanintharyi (1787 and 1792).
Also note that the border runs through a mountaineous area called the Tenasserim Hills, which acts as a barrier between the two states.
(Map from Wikipedia Commons)