One of the things usually taken to be distinctive of mathematical and logical truth is that such truths are in some very strong sense necessary, i.e., they could not have been false. Assuming that it is in fact true that 2 + 2 = 4, how could that have failed to be true? (Or, to take a logical example: How could it fail to be true that, if Goldbach's conjecture is true and the twin prime conjuecture is also true, then Goldbach's conjecture is true?) Presumably, the answer to this question depends upon what, precisely, one thinks "2 + 2 = 4" means, but it is hard to see how one could accept the statement that 2 + 2 = 4 as both meaningful and true and think that it might not have been true. It's important to be clear that this statement does not say anything about how actual objects behave, e.g., that if you put two oranges on a table with two apples and no other pieces of fruit, then you'll have four pieces of fruit. Weird things might happen in some worlds, but that would not make it false in that world that 2 + 2 = 4. It might make it uninteresting or irrelevant, but that is all. It's also important to be clear that we are not talking about whether the sentence "2 + 2 = 4" might have been false. Of course it could have been false, since "4" could have meant what "5" means, and then "2 + 2 = 4" would have meant what "2 + 2 = 5" does mean and so would have been false.
Precisely what makes the statement that 2 + 2 = 4 true is not a question I'm prepared to answer here, however. (I'm not sure I'm prepared to answer it anywhere.)
The question about physical law is less clear. Some people have entertained the view that the most fundamental physical laws are, like mathematical laws, necessary, i.e., that there could not have been a world in which they were false. Sometimes this view seems to be tied up with some idea of the form: The laws are what tell us what mass, force, etc, are, and so if those laws did not hold, there wouldn't be masses, forces, etc. (Thomas Kuhn held a view of this sort at some times.) But most people seem not to care for this view and so regard the laws of physics as contingent, i.e., not necessary. That is just to say that the laws might have been otherwise. As has been noted by Hawking, among many others, universes in which the laws were different probably would not support life, or even be very stable. Our universe seems to be "just right", as Goldilocks famously said. But that does not mean there could not have been such universes, and some physicists, like Hawking, again, actually think there are all those other universes. (For what it's worth, however, and while we're on the topic, I think Hawking's recent remarks on the relevance of all of this to the question whether there is a divine being are not worthy of a man of his intelligence.)
By the way, you will sometimes see people talk about something called "physical necessity". This is a "relative" form of necessity, and it means: necessary, given the laws of physics. But what is physically necessary need not be necessary in some stronger sense: what could not have been otherwise, period, and not relative to anything else.
So, what do we have? Logical and mathematical truths are necessary. Physical truths are not (assuming we do not take the other view). So the laws of physics could have been otherwise, whereas the laws of logic and mathematics could not.