Simply copy and paste the following snippet into a code block. It already cycles through all posts so do not put this into a repeater/loop.
<?php
$categories = get_categories(array(
'orderby' => 'name',
'order' => 'ASC'
));
if (!empty($categories)) {
echo '<ul>';
foreach($categories as $category) {
$category_link = get_category_link($category->term_id);
echo '<li><a href="' . esc_url($category_link) . '">' . $category->name . ' (' . $category->count . ')</a></li>';
}
echo '</ul>';
} else {
echo '<p>No categories found.</p>';
}
?>