I associate "my bad" with sports. In basketball, for example, someone may attempt to make a quick pass to a teammate, but the ball goes out of bounds. Was it simply an ill-conceived pass, or should the would-be receiver have been paying more attention and made the catch? As both team head to the opposite end of the court, the guilty party may acknowledge to the teammate "My bad."
It's thus an acceptance of responsibility for the misconnection, miscommunication, or whatever— but it's also intrinsically evanescent. If the screw-up were major, "My bad" would be an inadequate and indeed trivializing response. Better form would be to say, "I [messed] up, and that's on me!" or something similarly considered and self-reproachful.
As the poster suspects, the difference between "my bad" and "my mistake" or "my error" is one of register and informality. I've heard people use "my bad" in playground sports in California (where I live) for almost three decades now; in fact, all too often I say it myself (owing to my problematic level of athletic skill). In an in-game milieu, it is not—as the coverage in Urban Dictionary (cited in Centaurus's answer) makes it out to be—a form of "apologizing without actually apologizing." I would say, rather, that in the midst of a sporting event it is an exceedingly brief apology without melodramatic garment rending or waste of breath, but a genuine apology nonetheless.
It may be that in fratboy/bro-speak, "my bad" is used as an utterly insincere acknowledgment of error about which the speaker doesn't really give a rat's ass (so to speak). But in sports it retains its original force as an expression of culpability and regret—and meanwhile the game goes on.