Two particles, two different jobs
吧 and 吗 both sit at the end of a sentence but do completely different work. 吗 converts a declarative statement into a neutral yes-no question: 你吃饭 (you eat) becomes 你吃饭吗 (do you eat?). 吧 adds softness: it can suggest (吃饭吧, let us eat), guess with confidence (你饿了吧, you must be hungry), or show reluctant acceptance (好吧, fine). They never substitute for each other because they send different signals.
吗 = yes-no question
吗 only works with declarative sentences to turn them into yes-no questions. 他来 (he comes) becomes 他来吗 (does he come?). You cannot use 吗 with a question word like 谁 or 什么; those sentences are already questions. 他是谁吗 is wrong; 他是谁 (who is he?) is complete on its own. 吗 is the simplest Chinese question marker and the one most learners hear first.
你喜欢吃中国菜吗?
Nǐ xǐhuān chī Zhōngguó cài ma?
Do you like eating Chinese food?
吧 = suggestion or soft command
When 吧 follows a verb or clause, it turns a command into a suggestion: 走 (go) is an abrupt command; 走吧 (let us go / go now) is a friendly invitation. 我们吃饭吧 (let us eat) is the standard way Chinese speakers propose an activity. Without 吧, 我们吃饭 sounds like a plain statement of fact. The particle 吧 is what moves the sentence into "let us / why not / come on" territory.
我们明天早点出发吧。
Wǒmen míngtiān zǎo diǎn chūfā ba.
Let us leave a bit earlier tomorrow.
吧 = assumed-answer tag question
吧 at the end of a declarative sentence turns it into a confidence-heavy tag question: 你是美国人吧 (you are American, right?). The speaker already believes the answer and is just confirming. This is different from 吗, which is genuine uncertainty: 你是美国人吗 (are you American? I do not know). Use 吧 when you have a strong guess; use 吗 when you really need the answer.
吧 = reluctant agreement
好吧 (fine, okay then) is the tonal classic: the speaker accepts something with mild resignation. 行吧, 就这样吧, 那好吧 all express a "fine, if we must" vibe. This usage has no equivalent with 吗. When 吧 follows an adjective or short acceptance word, it softens the acceptance and adds a hint of "not ideal but okay".
A: 我们去那家店吧? B: 好吧,去吧。
A: Wǒmen qù nà jiā diàn ba? B: Hǎo ba, qù ba.
A: Let us go to that store, okay? B: Fine, let us go.