How can I update the field of the entity?
The QueryInterface::execute() method returns either an integer or an array, not an object. It is a good idea to check api.drupal.org (if you don't use an IDE), or let your IDE do the work for you with intellisense.

It probably would be easier to use loadByProperties, which loads the entities for you. However it is definitely useful to get the query object, but you need to call loadMultiple.

$entities = \Drupal::entityTypeManager()
  -&gt;getStorage('question')
  -&gt;loadByProperties(['key' =&gt; $key]);

if (!empty($entities)) {
  $entity = reset($entities);
  $entity-&gt;set('key', 'new_value');
  $entity-&gt;save();
}