Brazil was playing both sides, much like Sweden. Profiting from the war while staying out of it. Brazil only joined the war because the US gave big loans to Brazil to fund the creation of steelworks factories to kickstart the steel production in the country. The sinking of the ships was just the official excuse to declare war, but Brazil was aligned with the US a few years before that.
From:
https://guides.loc.gov/brazil-us-relations/brazil-world-war-...
> Foreign Minister Oswaldo Aranha's five-week visit to the United States earlier in the year secured Brazil substantial lines of credit, loans, and technical assistance for the development of Brazilian rubber and mining industries. On September 26, 1940 the United States and Brazil signed agreement for the financing and construction of the Volta Redonda steel mill. By the end of 1940, Brazil had privately resolved to throw its lot in with the Allies.
I recommend reading the whole article, very interesting. I remember my history teacher in high school actually teaching this (he mentioned only steel, not rubber), I am very surprised this fact is downplayed and a lot of Brazilians don't know about it. I remember my teacher also mentioning that Brazil tried to secure similar deals with Germany but with no luck, but I can't find any sources for that.