EAST RUTHERFORD, N.J., June 2— Sao Paulo took advantage of some serious lapses by the Cosmos tonight and defeated the North American Soccer League champions, 3-2, in a second-round match of the Trans-Atlantic Challenge Cup.

Careca, the elusive and speedy center forward, scored all three goals for the Brazilians before a crowd of 26,641 at Giants Stadium. Two of them came after mistakes by Andranik Eskandarian and Vlado Bogicevic. He scored the winning goal with a minute left after a long breakaway.

On that goal, Careca beat Hubert Birkenmeier, the Cosmos goaltender, who had come off his line to narrow the angle. Careca slipped the ball under Birkenmeier, who had dived to his right.

Bogicevic and Julio Cesar Romero scored the goals for the Cosmos, who suffered their first defeat against a foreign team in the fouryear history of the tournament, which concluded with a doubleheader here on Sunday afternoon. Four-Way Tie

All four teams - the Cosmos, Sao Paulo, the Seattle Sounders and Fiorentina of Italy - will enter Sunday's games with two points each from a victory and a loss. The two foreign teams will meet before the American teams face each other.

The Cosmos defeated Fiorentina, 4-1, and the Sounders defeated Sao Paulo, 4-2, in the first round. Fiorentina then edged the Sounders, 1-0, Wednesday night in Seattle on a goal by Giuseppe Bellini in the 73d minute. If there is a tie, the difference in goals scored and goals allowed will determine the champion. If there is still a tie after that, the team with the most goals will be the champion.

Careca opened the scoring in the 25th minute after Eskandarian lost a foot race against Ze Sergio on the left side of the attack, with Ze Sergio passing to Careca for the goal from 10 yards away.

Bogicevic tied the game in the 34th minute on a well-executed giveand-go with Romero. In the 74th minute, Romero scored, assisted by Eskandarian and Franz Beckenbauer.

The Cosmos were outplayed for almost the entire game. After five straight impressive victories, the Cosmos lacked organization and coordination, passing sloppily and getting little support in midfield, especially from Roberto Cabanas, who was replaced by Angelo DiBernardo in the 70th minute.

''We didn't play the way we did the last few games,'' Coach Julio Mazzei said, ''but it was individual mistakes that cost us. The second goal was a total gift, a total lapse of concentration.''

Mazzei, referring to Sao Paulo's second score, would not fault any player by name. But it was Bogicevic who passed the ball back to Birkenmeier after a goal kick while the Cosmos' goalkeeper was looking the other way. Careca intervened and put the ball in the net, tying the game, six minutes after Romero had put the Cosmos in the lead.

''I was surprised to see them make mistakes like that,'' said Sao Paulo's Oscar, who played for the Cosmos in 1980. ''I was also surprised that the referee didn't make a call in the last goal because some people thought it was offside,''

Oscar was released by the Cosmos before the end of the 1980 season and returned to Brazil, where he became the captain of the national team.

Marinho, who played for the Cosmos in 1979, also played for Sao Paulo tonight, but he was no real threat on attack and had difficulty on defense. Oscar and Marinho were upstaged by Careca, who was the leading scorer in Brazil last season with 22 goals.

''Careca was supposed to play center forward for us in the World Cup in Spain last summer,'' Oscar said, ''but he got hurt a week before the World Cup started. He's a scorer. He has a lot of technical ability.''

This is the first time in the history of the tournament that all four teams go into the final day tied in points, although the Cosmos have the edge in goals.