I saw these red, green and blue rectangles in some research papers
- What is their purpose?
Their purpose is to signal to readers that the enclosed fields are not just some sort of cross-reference but that the fields are dynamic, in the sense that clicking on them will make the pdf browser jump to the corresponding external or internal link.
- Does including them in the paper signify higher expertise or anything of that kind?
I'm not sure that any one thing can unambiguously signal "higher expertise". Producing the color rectangles does signal, I believe, that the author has left the Stone Age behind. (Aside: A friend of mine, who is a mathematician, once told me, "Most mathematicians are Neanderthals." [!] I suppose that this friend would concede that writers who can create hyperlinked cross-references and citation call-outs may be classified as Homo sapiens sapiens...) Assuming the document was created with LaTeX, it also signals an at least passing acquaintance with (a) knowing how to load the hyperref package and (b) not hard-coding cross-references in the document but, instead, using commands such as \label, \ref, \eqref, \autoref, \cref, and \cite to create the cross-reference and citation call-outs.
- How are they included in a paper?
The colored boxes are generated by LaTeX if (a) the document loads the hyperref package and (b) the author uses commands such as \label to create "anchors" and commands such as \ref, \eqref (for cross-references to equation numbers), \autoref and \cref. To create hyperlinked citation call-outs -- such as the numbers 28, 480, and 492 in your screenshot -- it's necessary to know how use a suitably modern citation management package (natbib, apacite, and biblatex come to mind) and an external program (bibtex or biber) to create the formatted bibliography.
On a side note, an interaction designer would promptly say that this method of using colours looks ugly
You are not the only one who holds this belief! Indeed, see the posting better default colors for hyperref links for currently-ongoing efforts to come up with better color schemes.
figureenvironments; and green represents citation call-outs. Click on a green box and -- assuming you're using a pdf browser that's reasonably modern -- the viewer will take to the corresponding entries in the bibliography. – Mico Feb 16 '20 at 12:32hyperrefpackage lets you create two types of clickable links: colored rectangles (as in your screenshot) and by colorizing the text directly. The former is the default; to get colorized text, it's necessary to specify the optioncolorlinks. FWIW, most journals don't use color rectangles but, rather, colorized text to indicate hyperlinked cross-references. – Mico Feb 16 '20 at 12:50