Which files do I need to edit to alter webform #states with hook_form_alter?
Ok, if you need to rely on custom dev, you can indeed use hook_form_alter().

It would work if you set it in your mytheme.theme file but for unrelated theme issues I prefer to rely on custom modules.
To create your module:


Create a mymodule.info.yml file in the folder /modules/custom/mymodule of your Drupal website. See this page for providing your file with the minimal content to have your module detected by Drupal.
With only this file you should be able to enable your module
Create a mymodule.module file at the same level as your .info.yml file
In your .module file (or mytheme.theme if you chose not to create a module), add the following:



function mymodule_form_alter(&$form, &$form_state, $form_id) {
  // Target your form
  if($form_id == "your_form_id") {
    // Use Devel Kint module to display the architecture of your form and make it easier for you to find the elements you wish to alter
    kint($form); 
    // Now you can access the elements of your form and edit the desired ones

    // Hide checkbox "my_checkbox_name" if checkbox "my_other_checkbox" is checked
    $form['my_checkbox_name']['#states'] = array(
      'invisible' => array(
        ':input[name="my_other_checkbox"]' => array('checked' => TRUE),
      )
    );
    // Make field "some_input_text" required if input field "some_other_input" is filled with value 'hello'
    $form['some_input_text']['#states'] = array(
      'required' => array(
        ':input[name="some_other_input"]' => array('value' => 'hello'),
      )
    );
  }
}

I recommend you to have a look at this page for the list of available #states and some examples as well.

Happy coding!