This occurs more frequently in cases of sex tourism (most particularly in countries like Thailand), and online gambling.
A few years ago at a previous employer, we had a client in Costa Rica who made online gambling applications who hired us to do an application assessment (preventing cheating and things like that); and it was only after we had started performing the assessment that I happened to inquire in a meeting with our legal department as to whether this was actually legal for us to do.
As a result of that meeting, we had to stop work on the assessment immediately, and not do any invoicing, as our lawyer thought that charging for that assessment would be a pretty clear violation of the law.
And actually, I'm not certain that your lawyers were correct in stating that the work was illegal. It's illegal to operate an online casino in the US. That's not the same as it being illegal to develop software that can be used by an online casino. If the casino in question was serving US customers, then you might be considered an accomplice in a crime. If they were only serving customers outside the US, I seriously doubt you'd be guilty of any crime.
I concur that it was probably a more complicated legal matter, but our counsel was pretty confident that this would have been problematic.
Were they allowing US customers to use their site? If so, you were might have been in a gray area. I agree with your legal dept that it could have been problematic either way. Not necessarily illegal, but not worth the hassle.
Some laws are explicitly applied extraterritorially; for example, the U.S. has in recent years been prosecuting Americans who travel to other countries to pay for sex with minors, even if legal in the destination country. Drinking when under 21 isn't in that category, though. I have no idea if jailbreaking a phone is. Although, even without extraterritorial application, there might be some kind of U.S. contract violation if the person returns to the U.S. and continues to use the phone.
Thanks for the sentiment, but on legal grounds for end users I'm quite often not the most knowledgable ;P. In particular, I don't like travelling internationally, and I now actively avoid it, so I also tend to know less about how things work in other countries than more reasonable people. I work with some people here, however (who are asleep currently) that have spent a bunch of time researching the landscape of international law with regards to jailbreaking, but they probably themselves only focussed on "citizen of that country in that country".
What I will say I tend to know more about than average is "stuff that affects myself and my friends", but the reality is that as an end user of these tools, you really aren't ever going to be prosecuted: I thereby would tend to care more about "what if someone took a trip to a conference in Germany, built an unlocking tool with some friends there, and released it while abroad?", and for that situation I can dig up enough to make it sound sketch (although the extent to which DMCA exemptions help people who provide tools is at least in question).
Does that mean that if someone from the US that's under 21 travels to a country where the drinking age is lower (or non-existent?), legally drinking alcohol there would be illegal?