Code:
\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{float}
\pgfplotsset{compat=1.17}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows.meta, automata, positioning, matrix, calc}
\usepackage[RPvoltages, american,siunitx]{circuitikz}
\usepackage[margin=1in]{geometry}
\begin{document}
\begin{figure}[H]\centering
\begin{tikzpicture} [declare function = {buffHeight = 5; vertDis = 2;}]
\def\buffHeight{5};
\def\vertDis{2};
\draw(0,0) node[draw, minimum width = 1.25cm, minimum height = \buffHeight] (Samp1){};
\draw(\vertDis,0) node[draw, minimum width = 1.25cm, minimum height = \buffHeight] (Samp2){};
\draw(0,-6) node[draw, minimum width = 1.25cm, minimum height = buffHeight] (Samp3){};
\draw(vertDis,-6) node[draw, minimum width = 1.25cm, minimum height = buffHeight] (Samp4){};
\end{tikzpicture}
\end{figure}
\end{document}
Result:
\vertDis and vertDis gave me the same results as well as \buffHeight and buffHeight. But when I put in cm for the macro and the variable version i.e. \vertDis cm and vertDis cm, the former worked, while the latter gave me an error. Why does the macro version work with cm, but not the non-macro version?

{vertDis} cm? – Superman Oct 11 '20 at 06:37vertDis*1cmworks. – Symbol 1 Oct 11 '20 at 06:41minimum heightwill throw its argument into\pgfmathsetlengthor a similar macro (so that users can input1cm + 1in*3). But mixing functions and units confuses it. So better separate them by operators. (BTW,\vertDiswill be faster thanvertDis; so I always stick to the former.) – Symbol 1 Oct 11 '20 at 06:50\vertDisfaster thanvertDis? Also, besidesminimum height, what about the coordinates like\vertDis? – Superman Oct 11 '20 at 06:52\def\a{1.41421}and\pgfmathsetmacro\b{sqrt(2)}are expanded by TeX itself and is fast. On the other hand, a nullary function will undergo PGF's math engine, which is some heavy string-parsing stuff. For coordinates, such as(2, 3), they undergo another family of macros (\tikz@scan@one@pointetc). A way to distinguish them is that, while the default unit forline widthispt; the default unit of coordinates iscm. – Symbol 1 Oct 11 '20 at 07:00