Basically, the bid-ask spread may be formed in two different ways. First, it can be created by a broker (or trading intermediary) as a way to monetize for their service. Second, it can be created just by the differences between the limit orders placed by traders on an open market.
In traditional markets, the bid-ask spread is a common way of monetizing from trading activities. For example, many brokers and trading platforms offer commission-free services that only monetize by making use of the bid-ask spread. This is possible because they are the ones that provide liquidity to the market, meaning that sellers and buyers need to accept the price defined by the broker. Otherwise, they cannot participate in that market. In other words, they set the difference between selling and buying prices and make profits from it, essentially buying at a lower price from sellers and selling at a higher price to buyers.