I’m not exactly sure what your seeing or why, but your if statement is likely the cause since it will give unexpected results
if (get_sub_field('brand_name') == the_title()) {
the_title() echos the title of the post so every pass through the loop is echoing the title. I don’t know what results from attempting to compare a value to an echoed value.
try using get_the_title()