How to align underlines in a cases environment

I would just work with phantoms in this case.

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsmath}

\begin{document}
\[
f(t)=\begin{cases}
    2t+1&\text{if \(0\leq t\leq2\)},\\
    \underline{\phantom{2t+1}}&\text{if \(\underline{\phantom{0}} <t<\underline{\phantom{2}}\)},
    \end{cases}
\]
\end{document}

enter image description here


The \hrulefill command expands to

\leavevmode \leaders \hrule \hfill \kern \z@`

So one way to do what you want is to use \hrule, or better \rule, instead of \_. If you define

\newcommand\blank{\rule{2mm}{0.4pt}}

then you can use it to produce:

enter image description here

Here is the full code:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsmath}
\newcommand\blank{\rule{2mm}{0.4pt}}

\begin{document}
\[
f(t)=\begin{cases}
    2t+1&\text{if \(0\leq t\leq2\)},\\
    \hrulefill&\text{if \(\blank <t<\blank\)},
    \end{cases}
\]
\end{document}

Since you are already using mathtools I'd also recommend using the cases* environment so that you can omit the \text{...} commands when using cases. Unfortunately, \hrulefill does not work inside a cases* environment, so here is a fancier version of the \blank command that takes an optional argument that sets the length of the blank to the length of the supplied content:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsmath}
\newcommand\blank[1][$\_$]{\rule{\widthof{#1}}{0.4pt}}

\begin{document}
\[
f(t)=\begin{cases*}
    2t+1&if \(0\leq t\leq2\),\\
    \blank[$2t+1$]&if \(\blank <t<\blank\),
    \end{cases*}
\]
\end{document}

The output is similar to before. except that the default length of \blank is now the length of \_, which is slightly shorter.