To avoid or mitigate wobbles on dirt and sand (where wobbles are just a fact of life), you keep the arms loose, stand up, look as far ahead as possible, and speed is your friend (look up, stand up, open up). The idea is to keep the weight shifted back, load off the front, and to let the front wheel’s angular momentum solve the hard problems.
Not sure what works best on pavement; never had to deal with wobbles there. It seems to happen mostly to bikes with sportier suspension than I ride; the kind where if you roll over a coin you can tell what year is stamped on it. I also ride pretty cautiously on pavement; you can’t just run over the handlebars and roll in some dirt.