I've created a solution that will hopefully get what you're looking for. Note that this solution uses a reoccurring trigger that would run as often as you wanted (similar to the example you shared). This means when you add, delete, or modify an item the count wont update until the flow runs again so would be a delay. This also updates every item regardless of whether it needs to be updated or not.
How many items do you have in your list?
For this example, I'm using the following list. Title contains the names, and Count (Number data type) will contain the number of times the Title appears in the list.

See full flow below. I'll go into each of the actions.

Reoccurrence is set to run on a schedule (up to you how often).

Get items retrieves all the items from the list.

Select creates a simple array of all the Titles in the list. Note that the Map is using Text mode (see arrow on screenshot).

Apply to each uses the output from the Select but uses the union expression passing in the Select output twice so it removes any duplicates. So, the Apply to each will iterate over each of the unique Titles. The expression used is:
union(body('Select'), body('Select'))

Filter array will use the current Title and filter the items where the Title is equal to the current Title. The first time through the loop, the Title would be Ball, so the Filter array would filter the items in our list where the Title is equal to Ball. The second time through the loop, the Title would be Dog, so the Filter array would filter items in our list where the Title is equal to Dog, etc.

Apply to each Update uses the output from the Filter array so it iterates through each of the items returned.

Update item will update each of the items with the current number of instances for that Title. The expressions used are below:
//Id
items('Apply_to_each_Update')?['ID']
//Title
items('Apply_to_each')
//Count
length(body('Filter_array'))

After the flow runs, we would see the following output.

----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.