The story
From butter + cup. Both sense 1 and 2 are from the flowers' association with butter, from their yellow colour. Compare butterflower for a similar derivation; outside of English, compare Dutch boterbloem, German Butterblume.
Etymology from Wiktionary, CC BY-SA 4.0.