First of all from a best practive standpoint, dont communicate with the data layer from a view.
Pass the data to a view using the controller.
For you problem:
Fix the if statement, you're trying to echo the condition.
<select class="form-control form-control-alternative" name="category">
<option selected value="{{$category->id}}">{{$category->name}}</option>
@foreach($$categories as $cat)
@if($cat->id !== $category->id)
<option value="{{$cat->id}}">{{$cat->name}}</option>
@endif
@endforeach
</select>
invoke function of my controller
public function __invoke(Category $category)
{
$categories = Category::all();
return view('machine.edit', compact('category', 'categories'));
}