If you commit a crime near a single or several strangers nearby they will start to run away and will attempt to report to the authorities. You can stop a witness from doing so by chasing after them and confronting them. If they stop and plead, you can continue threatening them until they promise to turn a blind eye. At this point, you can beat them up and/or rob them as well.
Another method is by chasing after them on horseback and capturing them using a lasso. This is recommended if the witness is also on horseback.