See, both are used to retrieve something from the webelement.
getText() simply retrieves the visible text present in the webelement. So, this is the text inbetween 2 HTML tags (openning & closing tags)
getAttribute() however, retrieves the value of attribute(s) of that webelement. So, this is the key & value pairs inside the tags(mostly openning tags).
Look at the below example to understand this better.
<input attra='1' attrb='2' attrc='3'>Edureka</input>
getAttribute(attra) --> you get value '1' returned
getAttribute(attr2) --> you get value '2' returned
getAttribute(attr3) --> you get value '3' returned
getText() --> with no parameter returns only 'Edureka'.