joins two codes and alternates between them with a button

The usual process for developing a new program is to start with a set of requirements. What are yours?

You will have some state - auto-avoidance or user-(mis)controlled. What will cause a change from one state to the other?

Once you know that, writing the loop() function to call either autoAvoid() or userControl() on each iteration, after determining if a change is needed, is trivial. Writing the functions to be non-blocking isn't that difficult.