When entity get returns array, do this

You are using get with fieldname and you are getting array as result, to get value as string, use getString() method like below

$entity->get("fieldName")->getString()