field from category not available via craft.categories
Because your category variable is no object of type craft\elements\Category but an ElementQuery in order to fetch the category you need to use the one() function

{% set category = craft.categories.slug(filter).one() %}  
{% if category != null %}
    {{ category.titleTag }}
{% endif %}


Your {{category.titleTag}} printed the search criteria. Imagine you would like to set other conditions in your query: how is Craft supposed to know when your query ends?