Fetching details from the dictionary...

by chance; by accident; accidentally; happen to (be, do); unexpectedly; casually
occasionally; once in a while; now and then
たまたま入った店がとてもおいしかった。
A shop I happened to walk into was really good.
たまたま同じ電車に乗り合わせていた。
We happened to be on the same train.
たまたま見つけた本がとても面白かった。
A book I found by chance turned out to be great.