I did not read very carefully who is A and who is B. But if the excavation was carried out jointly and both knew from the beginning that after the construction of the garage and parking space both sides were to be refilled to the original level, then it raises the question for me why B, with this knowledge, does not also have a garage built on the side that is earth pressure secure and now passes the responsibility to A. Maybe this is legally more complicated.
If the process and the excavation had been independent of each other, it would be clear to me (warning, just a layperson’s opinion!): If B had excavated first and built the garage, he would have had to secure his garage laterally against earth pressure because A would then have been higher. If A had excavated first, he would have had to secure property B for the duration of the work and then could have refilled normally, and if B later built a garage below ground level, he would then have had to build it earth pressure secure on the side.