According to Smithsonian Magazine, 1 in 4 cowboys were black. I suspect popular culture (movies) are what's to blame for this misconception. Many fled to the West after the Civil War to find work.
https://www.smithsonianmag.com/history/lesser-known-history-...