If I understand correctly what you want to do, you can try using focus-within. Below is an example html applying your code.
.mat-form-field {
border: 2px solid gray;
}
.mat-form-field:focus-within,
.mat-form-field:active,
.mat-form-field input:checked {
border-color: green;
color: green;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</head>
<body>
<form>
<mat-form-field class="matFormField">
<mat-label>Name</mat-label>
<input matInput [formControl]="name" required>
</mat-form-field>
</form>
</body>
</html>
If I misunderstood, let me know so I can look into another approach.