Assign an action to a simple button
In Method 2 you want to add the form as an element in the $build array.

Should be something like this:

$build['my_form'] = \Drupal::formBuilder()-&gt;getForm(Drupal\myModule\Form\myModuleForm::class);


Also you don't need to return anything, $build is passed by reference, so anything you add to it will stick.