By leaving the JCPOA in May 2018, the US did not cancel the agreement.
The agreement continued, with the agreement of the remaining parties.
The US was not in violation because no rule was broken. There is no rule in the agreement stating that a signatory cannot exit the agreement unilaterally.
Furthermore, under US law, the JCPOA was not even a treaty, making exiting the agreement even easier for the US President.
In May 2019, Iran announced an “increase” in uranium enrichment activity in violation of the terms of the agreement.
In May, Iran announced it was quadrupling its uranium production
capacity and mid-June it would exceed the stockpile limit by the end
of the month.
Of course the relation of such pronouncements to the truth is open to debate. The move was leveraged by both the Iranian regime and US domestic opposition, to discredit the incumbent US administration.
Counterintuitively, Iranian President Hassan Rouhani indicated in November 2019 that Iran was continuing to pursue the JCPOA agreement to win the benefits of a lifted arms embargo in 2020 as part of the terms of the deal.
As to whether Iran violated the JCPOA, the wording of the agreement is such that as long as a majority of the EU+3 are happy with the evidence provided by Iran, then no violation occurs (para. 78).
Until May 2018 the IAEA maintained that Iran had been in compliance with the JCPOA. This is the source of the numerous "Iran is [or was] in compliance" claims.
However, since the original signing of the agreement in 2015 - including before the Trump administration - Iran repeatedly (2015) stated (2017) that IAEA inspectors are denied access to their military sites - even those at which nuclear research was previously known to have been conducted.
Remember: the entire purpose of the JCPOA is to ensure Iran does not militarise nuclear technology.
From the preface (my emphasis):
[the signatories] welcome this historic Joint Comprehensive Plan of
Action (JCPOA), which will ensure that Iran’s nuclear programme will
be exclusively peaceful...
Iran therefore stayed in "compliance" of the agreement on the volition of the EU+3, and then latterly, after the 2016 Presidential Election, the EU+2 (ie. without the US).
In other words: if a majority of the EU+3 were to demand access to an Iranian military facility to check for compliance, then Iran would likely immediately fall into non-compliance.
But the signatories other than the US never requested such access, and hence Iran stayed in compliance.
Compliance checking necessarily involves verification of stated compliance. Simply accepting Iran saying "we are in compliance" does not suffice. If we fully trusted Iran, then the JCPOA and the inspection regime would not be necessary.
A thorough check, therefore, cannot be completed without access to military sites; yet, per the above, no violation occurs until the a majority of the signatories agree it has. The US executive was, for good reason, not happy with the inability of IAEA inspectors to access Iranian military sites for compliance checking.
The US requested access for the IAEA inspectors, and were denied. The terms of the treaty gave them no veto power, so they exited the agreement in May 2018 - as was their right.
The reason why the IAEA never requested access to military sites for the checking of compliance - when it would seem a straightforward matter of due diligence - is open to speculation.
With the persistent refusal to ask for inspectors' access to likely sites of nuclear weapons development, the nature of the JCPOA changes hue. It becomes a fig leaf - a pretence - that the Iranian regime is on a path to rehabilitation. Clearly all sides know this.
In addition to the nuclear-related aspects of the JCPOA, it encodes more than $100 billion in sanctions relief for the Iranian regime.
Also noteworthy, is the January 2015 flight, in an unmarked plane, of $400 million in cash to Iran. The Obama administration denied this was payment for the release of hostages.
The Wall Street Journal reported that this was the only the first instalment of a $1.7 billion payment to Iran. These "repayments" were claimed to settle an outstanding "debt" to the Iranians for non-delivery of military equipment in 1979.
Due to the fungibility of money, these payments can easily be argued to have subsequently been used to support Iran's various proxies against the coalition effort in the region.
This debt repayment and sanctions relief at a time when the theocratic regime was involved in a kinetic proxy war with the US; plus the fact that the agreement doesn't actually close-off a path to a bomb informs us about possible motivations for the US (and possibly others) signing the JCPOA.
One can speculate that the deal - presented as a way to prevent an Iranian nuclear break-out - was, instead, realpolitik designed to empower predominantly-Shia Iran as a counter to other powers in the region: Israel and predominantly-Sunni Saudi Arabia. Possibly to engineer a regional stalemate of sorts.