Why did Poles attack Czechoslovakia and annexed the Czechoslovak territory in 1938, one year before the WW2?
Casus belli: Territorial claims, based on supposed Polish ethnic majority in those regions.
--
To understand the roots of this conflict we need to realize that various parts of Silesia changed hands several times throughout many centuries. The kingdom of Poland, the kingdom of Bohemia, the kingdom of Hungary and the kingdom of Prussia. There is little point in arguing over which 20th century state had stronger historical claims to Silesia because neither Czechoslovakia nor Poland based their claim on historical rights as their sole main argument.
--
During WWI (1914-1918), Polish, Czech and Slovak pro-independence politicians were already busy preparing the birth of their respective independent states and in order to succeed they needed approval from victorious superpowers.
The Czechoslovak party claimed that historical borders of the lands of the Bohemian crown haven't changed much up until the 18th century (the loss of Silesia in favour of Prussia) and that those borders matched natural mountainous borders. What did the Czechoslovak party stress out, though, was the economic/industrial integrity of these lands. There were rich coal resources in the area and also the only railway connecting Bohemia with Slovakia and Carpathian Ruthenia through mountains went through there.
The Polish party based their claim on ethnic and national self-determination principles.
We need to clarify here that although the Czechoslovak claim might seem as "outrageous" from a present point of view (claiming some land simply "because we need it"), back then it was a fair and reasonable claim for newly born countries that couldn't effectively run their economy without such key resources and infrastructure/industry elements. At the same time, a self-determination right of nations was also a fair and reasonable claim to create an indepentent Polish state, although not a right specific about regions. So there we were in the year of 1918 with both newlyborn countries having a valid claim to the disputed territory.
--
Both parties initially agreed that in Cieszyn Silesia specifically, Czechoslovaks won't demand historical Bohemian borders but their minimum infrastructural/industrial needs will be addressed.
It was a provisional regional agreement and a subject to a future border demarcation by experts from both parties. Before proper steps could be finished though, matters spiraled out of control following the dissolution of Austria-Hungary; Czech and Polish national bodies in the region had to act to maintain order and proclaimed the region to belong under Czechoslovakia or Poland respectively.
Again, to maintain order, both Czech and Polish local national bodies signed a temporary agreement on 5th Nov 1918. How the agreement should be interpreted is a source of disagreement even to this day. The Czechoslovak party claimed that the agreement didn't feature ethnic division and only adressed responsibility areas of both local national bodies (not giving the territory to either state yet). Also strictly stating that border demarcation will be resolved on governmental level of both states.
The Polish government confirmed this agreement, while the Czechoslovak government did not and considered it binding only on regional level, not state level. In practice though, the Czechoslovak government tolerated Polish actions in the region. Such approach couldn't prevent problems because the agreement was only provisional, lacked eg. court subordination arrangement between cities Opava, Brno and Krakow.
The Polish party started to administer the region as if it belonged to Poland, most importantly when the Polish government announced Polish elections to the Sejm on 26th Jan 1919, including Cieszyn Silesia in the elections. Thus going the "fait accompli" way about the dispute.
Following diplomatic talks between Polish and Czechoslovak governments weren't fruitful. The situation was even more complicated because while both states were already independent, they still needed international approval of their territorial actions.
The Czechoslovak government needed to secure the railway and asked for either French and Italian army to occupy the disputed region or to give approval to the Czechoslovak army, an acknowledged ally of WWI victorious allies, to take action.
With Polish Sejm elections coming and no reply from Paris, the Czechoslovak government took armed action in order to prevent Sejm elections in Cieszyn Silesia. In the following so-called Seven-day war (23th Jan - 30th Jan 1919) the Czechoslovak army secured the railway, stopped further advance and the dispute was brought to a peace conference in Paris. The Polish and the Czechoslovak government finally agreed to solve the dispute through international arbitration.
--
So if there was a solution reached through mutual agreement, why did then Poland renew those demands 20 years later?
There were several factors involved which probably contributed to the Polish party feeling injustly treated.
Poland, on contrary, wasn't really stable in its first independence months. Allies didn't trust Józef Piłsudski much due to his first 3 years in WWI spent on the side of Central powers and didn't initially acknowledge the Polish government appointed by him in Warsaw. They did initially acknowledge the Polish National Committee formed in Lausanne (1917-1919).
Poland had more serious existential issues to solve unlike Czechoslovakia, mainly the Polish-Soviet War (14 Feb 1919 – 18 Mar 1921). The Polish government likely agreed to the arbitration with Czechoslovakia in exchange for a promise of help from Allies against Soviets.
No major ethnic exchange of inhabitants was done between both states. Regional Poles were involuntarily made into a less than 1% ethnic minority in Czechoslovakia.
--
The Polish government took advantage of this ethnic sentiment during the interwar period and made sure to keep fuelling it. When the opportunity presented itself in 1938, they acted on the same casus belli like 20 years ago. The Czechoslovakian government, already crippled by the result of the Munich Agreement, accepted the Polish ultimatum without fight.