Tuberculosis (TB) remains a major public health concern because people do not develop lifelong immunity, and the disease can also spread through the environment. In this study, we develop a mathematical model consisting of susceptible-vaccinated-exposed-infectious-treated-recovered-bacteria (SVEITRB) dynamics to understand the spread of recurrent TB, taking into account environmental transmission, reinfection, and preventive treatment strategies. The model divides the population into six human compartments and one environmental compartment representing bacteria concentration. Mathematical analysis confirms the positivity, boundedness, and uniqueness of solutions using the Picard–Lindelöf theorem. The stability of both disease-free and endemic states is analyzed using mathematical tools such as first approximation theory, Lyapunov functions, and LaSalle’s invariance principle. Our findings show that TB will persist in the population if the basic reproduction number \(\bf{R_{0} > 1}\) , and it will eventually die out if \(\bf{R_{0} < 1}\) . To determine which factors most affect TB transmission, we perform a sensitivity analysis of basic reproduction number R0. Results show that the progression rate, environmental transmission rate, and bacterial decay rate are among the most influential parameters. For example, a 10% increase in the vaccination rate η leads to an estimated 3.1% decrease in R0. Numerical simulations confirm that reducing environmental transmission and improving vaccination coverage can significantly lower infection levels. Finally, we use Pontryagin’s Maximum Principle to find the most effective time-dependent strategies for vaccination and treatment while minimizing costs. The results offer useful insights into planning more effective TB control measures. Our numerical results further show that a vaccination-therapy combination can best reduce the infection level. The adaptation of integrated vaccination and environmental factors plays a key role in treatment programs for long-term TB control.