B cells are created as "Naive", or non specific cells in the immune system. From there, they move to the spleen, where some of them are differentiated to fight different specific infections.
If an infection is new to the body, the B cell will form surface features that mimic the structure of the invading infection. The B cell uses this information to produce antibodies to fight off the disease.
This initial process is slow, and the B cells cannot produce an effective amount of antibodies for about 7-14 days. However, this is why many diseases resolve themselves without treatment within that time period.
However, after the infection is dealt with, certain B cells are retained and become "memory" cells. They are extremely long lived - once formed, they may last for the rest of the host's life. These cells can produce the same antibodies on demand without having to go through the initial process. A good metaphor is that it takes a tailor a while to take your measurements and cut a suit to fit. However, the measurement process does not have to be repeated to produce a new suit, and the same measurements can be used to produce suits that can be purchased "off the rack" by anyone with similar measurements.
The etiology of most autoimmune diseases is that B cells recognize healthy host tissue as foreign and start producing antibodies against it. This is why most autoimmune conditions are chronic and must be treated for the rest of the patient's life. Cancerous B cells cause myeloma, and since the cells are difficult to kill and are produced continuously by the body, myeloma is both deadly and hard to treat.