\documentclass[a4paper,12pt]{article}
\usepackage[english]{babel}
\usepackage{scalerel}
\usepackage{stackengine}
\usepackage{xcolor}
\usepackage{scalerel}
\usepackage{tcolorbox}
\usepackage{amscd}
\usepackage[all,cmtip]{xy}
\usepackage{calrsfs}
\usepackage[all]{xy}
\textheight=22.75truecm \textwidth=17cm \evensidemargin=-0.5cm
\oddsidemargin=-0.5cm \voffset-1.5cm
\pagestyle{headings}
\def\Spec{{\mathrm{Spec}\,}}
\def\Hom{{\mathrm{Hom}}}
\def\bHom{{\mathbf{Hom}}}
\def\bAut{{\mathbf{Aut}}}
\def\End{{\mathrm{End}}}
\def\Ext{{\mathrm{Ext}^1}}
\def\FEt{{\mathrm{FEt}}}
\def\Sets{{\mathrm{Sets}}}
\newenvironment{pf}
{\begin{proof}}
{ \end{proof}}
\newenvironment{function}
{\begin{center}
\begin{tabular}{rl}}
{\end{tabular}
\end{center}}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\begin{document}
\begin{tcolorbox}[colback=white!5!white,colframe=white!50!black, colbacktitle=white!75!black]
\begin{flushleft}
\textbf{\underline{How can we test whether a given set of polynomials $G$ is a Gröbner basis or not?}}
\end{flushleft}
\end{tcolorbox}
\end{document}
How do I fix this ? My writing is going outside the t-color box.

tcolorbox, but of the underline. You can find an explanation for this here or in the TeX FAQ for example. – epR8GaYuh Jul 08 '21 at 05:48tcolorboxhas options for flush left the texthalign=flush left? – CarLaTeX Jul 08 '21 at 05:58tcolorbox. For the paragraphs there is no problem, usually, please ask another question with an example of what you are not able to get. – CarLaTeX Jul 08 '21 at 06:22