Both ANSI, the American National Standards Institute (formerly the American Standards Association), and Ecma International (formerly the European Computer Manufacturers Association) are standards development bodies. They are not sister organisations, they were formed independently; ANSI is quite a bit older than ECMA.
ANSI and ECMA did similar things for different regions (on opposite sides of the Atlantic Ocean), with different areas of responsibility. ANSI has a much wider scope than ECMA (and Ecma), and different positioning: while Ecma develops standards directly, ANSI accredits standards and standards development processes. Ecma now considers itself an international organisation, no longer European only; ANSI operates only within the United States.
Some of their work overlaps, as demonstrated by their standardisation or accreditation of programming languages, and there are connections; in particular, both ANSI and Ecma have produced standards which have been ratified by the International Organization for Standardisation (ISO) — including ANSI C, ASCII, ISO 9660...
C ended up standardised by ANSI for procurement reasons. As Dennis M. Ritchie explained in The Development of the C Language,
The first edition of K&R was also insufficiently precise on many details of the language, and it became increasingly impractical to regard pcc as a ‘reference compiler;’ it did not perfectly embody even the language described by K&R, let alone subsequent extensions. Finally, the incipient use of C in projects subject to commercial and government contract meant that the imprimatur of an official standard was important. Thus (at the urging of M. D. McIlroy), ANSI established the X3J11 committee under the direction of CBEMA in the summer of 1983, with the goal of producing a C standard. X3J11 produced its report [ANSI 89] at the end of 1989, and subsequently this standard was accepted by ISO as ISO/IEC 9899-1990.
From Bell Labs’ perspective, the governmental aspect would have led to requiring a standard approved in the US, which would mean involving ANSI. C isn’t the only or even first language in this situation; the first was Fortran, followed by COBOL.
As for why ECMA ended up standardising JavaScript as ECMAScript, the story suggests that this was a case of politics, time pressure, and knowing the right people. Brendan Eich, JavaScript’s creator, has spoken about this a number of times, e.g. in this podcast; in the latter, he explains that Microsoft was putting pressure on Netscape around JavaScript, so Netscape decided the best way to avoid having Microsoft wrest control of JavaScript (by way of the potentially de facto standard implementation in Internet Explorer) was to standardise it, and it happened that Carl Cargill, Netscape’s standards representative, knew Jan van den Beld, who was ECMA’s secretary general at the time. This Wired article on the subject puts it thus:
With the Netscape-originated and widely used scripting language JavaScript, Netscape avoided the W3C altogether - because, Cargill says, it was "the most contentious spec ever produced," and the company wanted a review board that "wasn't mired in politics."
Cargill says Netscape sought out ECMA to approve JavaScript last November because it believed the lesser-known standards body would be able to quickly and objectively administer the process. Microsoft charged Netscape with purposefully delaying the approval process, and with failing to release JavaScript source code that could be integrated into its Internet Explorer browser. When Netscape sought ECMA approval, Microsoft and Cisco promptly joined the body's general assembly. An open standard "ECMAScript" was subsequently born in late June.