How do I draw and define two right triangles next to each other?
Welcome to TeX-SE! The issue you are seeing is caused by the fact that an empty line tells TeX to start a new paragraph. So all you need to do is to remove the empty line. Here I go a slightly different route and put the second triangle in a scope that is used to move it to the right. This allows you to more easily control the distance between the triangles, and their vertical relative alignment. Please note also that it is advantageous to draw them in one stretch and close them with -- cycle
because then the line joins look better.
\documentclass{article}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{tikz}
\usepackage{float}
\begin{document}
\begin{tikzpicture}
\draw (1, 0) node[below left]{$A$} -- node[midway,left]{$x+29$}
(1, 4) node[above left] {$B$}
-- (4, 0) node[below right]{$C$} -- node[midway,below]{$21$}
cycle;
\begin{scope}[xshift=5cm,yshift=0.5cm]
\draw (1, 0) node[below left]{$D$}
-- node[midway,left]{$12$} (1, 3)
node[above left]{$E$}
-- (3, 0) node[below right]{$F$} -- node[midway,below]{$x$}
(1,0)-- cycle ;
\end{scope}
\end{tikzpicture}
\end{document}
an alternative, using relative coordinates tikz
libraryquotes
for labeling lines in triangles:
\documentclass{article}
\usepackage{amsmath,amssymb} % amsfonts is loaded by amsymb
\usepackage{tikz}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}
\draw (0, 0) node[below] {A} to["$x+29$"] ++ (0, 4) node[above] {B}
to ++ (3,-4) node[below] {C}
to["$21$"] cycle;
\draw (5,.5) node[below] {D} to["$12$"] ++ (0, 3) node[above] {E}
to ++ (2,-3) node[below] {F}
to["$x$"] cycle;
\end{tikzpicture}
\end{document}